in reply to code optimization
I was actually looking at this paper which describes in the first 3-4 pages how to compare continued fractions and I was wondering if converting your fractions to continued fractions and then carrying out a continued fractions comparison algorithm(which Flajolet describes in the first link in this post) would lead to faster running times.
Except.. it's pretty hard to compete with the cost of a division(which is rather low).
In any case, if Perl doesn't cut it as far as execution time, I would go for XS, or a pure C version.
In Section
Seekers of Perl Wisdom