4 ms·
I'd be interested to see how Elixir does with an OTP-optimised redo. Probably still not great, but I feel like the example isn't playing to its strengths.
by midgetjones 8y ago
I'd be interested to see how Elixir does with an OTP-optimised redo. Probably still not great, but I feel like the example isn't playing to its strengths.
- comboy 8y agoWhat do you mean by redo?
- dnautics 8y agoOtp won't help. The benchmark itself is too synthetic to really matter as an analog for real world use cases where you would deploy elixir (or go or swift for that matter if we're being honest). Elixir cares about developer ease, high up time, lots of connections (network I/o). Do you need these things? Then you shouldn't care about the benchmark.
- chvid 8y agoWhat is OTP? Fibonacci optimised by memorising already calculated values is linear time and constant time if you use the analytical formular for it. But then it stops being an interesting micro benchmark (as is pointed out on the website).
- rkangel 8y agoOTP allows for work to be distributed across cores and get a speedup in some way proportional to that. It wouldn't be a fair comparison though, exactly like memoisation or constexpr. It's also an option that isn't unique to Elixir. Go is the obvious other candidate where the programming language helps, but all of the languages have support for parallelism.
- obahareth 8y agoThe example was indeed not playing to its strengths, it wasn't making use of tail call optimization. I made a PR to fix that: https://github.com/drujensen/fib/pull/33 https://github.com/drujensen/fib/pull/33
- thedufer 8y agoThat's obviously a better choice if you actually want Fibonacci numbers, but it defeats the point of a benchmark if you implement a completely different algorithm in one of the languages.
- lelf 8y ago18> timer:tc(fun fib:main/0). 2971215073 {59352962,ok} % 59s… slooow 19> hipe:c(fib, [o3]). % compile with Hipe {ok,fib} 20> timer:tc(fun fib:main/0). 2971215073 {12570352,ok} % 12.5s! PS that's Erlang, but it will be similar with Elixir.