Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Explain Fibonacci one-liner ??

by JavaFan (Canon)
on May 10, 2010 at 22:22 UTC ( [id://839319]=note: print w/replies, xml ) Need Help??


in reply to Re: Explain Fibonacci one-liner ??
in thread Explain Fibonacci one-liner ??

The JavaFan code is the fastest. My code is 2nd. There is no 3rd, 4th or 5th place. Things go "downhill" very fast (not just factor of 2x, 3x, but orders of magnitude).
Actually, so does yours. It's just not visible because of the very limited range. Upping the range to 1..90 gives:
Benchmark: running JavaFan, Marshall for at least 2 CPU seconds... JavaFan: 2 wallclock secs ( 2.18 usr + 0.00 sys = 2.18 CPU) @ 44 +81.19/s (n=9769) Marshall: 1 wallclock secs ( 2.00 usr + 0.00 sys = 2.00 CPU) @ 34 +2.50/s (n=685)
Also note that your move to put the assignment of $PHI inside the subroutine reduced the running speed by about 10% (it does 5063.11 iterations/s with $PHI only assigned to once).

Incrementing the range even further would increase the difference even more, but for some N between 90 and 100, F(N) no longer fits inside a 64bit integer. And I didn't want to spend the time to write a benchmark using Math::BigFloat/Math::BigInt.

Replies are listed 'Best First'.
Re^3: Explain Fibonacci one-liner ??
by Marshall (Canon) on May 11, 2010 at 00:24 UTC
    I don't want to write more benchmarks either. I think enough said about this. If the Op wants to beat it to death..he/she has a lot of info to work with.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://839319]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found