4 ms·
Fibonacci(50) Performance: Java C C++ D Go Terra (Lua) Lua-JIT (Lua)
- senthadev 12y agoYou should try to implement the Fib with tail call and then test it. http://en.wikipedia.org/wiki/Tail_call http://en.wikipedia.org/wiki/Tail_call
- dozzie 12y agoFirst he should implement it properly, remembering last two values at any time. His way is just plain outrageous.
- bjorg 12y agoI wonder if the author validated the results returned by Java for Fibonacci 50. Performance can increase significantly when correctness is not an issue. :)
- rjoshi 12y agoYes, if you look at the https://github.com/rohitjoshi/lang-compare/blob/master/fibonacci/results_fib_50.txt https://github.com/rohitjoshi/lang-compare/blob/master/fibon..., it print fibonacci (50) = 12586269025
- tasoeur 12y agoDoes anyone know why Java would be faster here? Is there any kind of optimization happening under the hood? (Automatic memoization?)
- deleted 12y ago[deleted]
- rjoshi 12y agoSee the updated blog again. It seems issue is with Clang/LLVM on MacOSX. I reran the test on Linux with Gnu g++ and it outperforms Java.
- igouy 12y agoBack in the day, when we didn't know any better... https://web.archive.org/web/20080729072224/http://shootout.alioth.debian.org/gp4/benchmark.php?test=recursive&lang=all https://web.archive.org/web/20080729072224/http://shootout.a...