[Shootout-list] Erlang fibonacci

Brent A. Fulgham bfulgham@debian.org
Sun, 13 Jun 2004 17:00:30 -0700


Einar Karttunen wrote:

>Hello
>
>The following should produce fibonacci faster in the same naive way
>*with* bytecode interpreter. The original is faster for the native case.
>
>fib2(0) -> 1;
>fib2(1) -> 1;
>fib2(N) -> fib2(N-2) + fib2(N-1).
>  
>
With this implementation there's not much difference between
the native and HIPE versions!

>Native compilation would make things really faster here (almost five
>times). Here is a short benchmark of the differences:
>
>27> timer:tc(fib, fib1, [20]).
>{1416,10946}
>28> c(fib, [native, {hipe, [o3]}]).
>{ok,fib}
>29> timer:tc(fib, fib1, [20]).     
>{286,10946}
>
>286 vs 1416 is a quite large difference...
>  
>
True.   But with the revised implementation HIPE doesn't show any 
advantage here.  Interesting....

-Brent