Settings

Theme

Fibonacci(50) Performance: Java C C++ D Go Terra (Lua) Lua-JIT (Lua)

joshitech.blogspot.com

4 points by rjoshi · 10 comments

Reader

4 threads
igouy

Back in the day, when we didn't know any better...

https://web.archive.org/web/20080729072224/http://shootout.a...

senthadev

You should try to implement the Fib with tail call and then test it. http://en.wikipedia.org/wiki/Tail_call

  • dozzie

    First he should implement it properly, remembering last two values at any time. His way is just plain outrageous.

    • rjoshiOP

      Here the comparison is not about the algorithm, but language with similar recursion logic.

      • dozzie

        Then he should have used appropriate function to calculate, Ackermann for instance.

bjorg

I wonder if the author validated the results returned by Java for Fibonacci 50. Performance can increase significantly when correctness is not an issue. :)

tasoeur

Does anyone know why Java would be faster here? Is there any kind of optimization happening under the hood? (Automatic memoization?)

  • rjoshiOP

    See 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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection