I’ve finished the juliaacademy course on the basics of julia and it ends with a very nice comparision of the sum function across multiple languages. I’ve changed some few things in the original code, now I’m getting the average time that the benchmarks function returns and also, i’m properly plotting it.
Just like @jling sugested, i will try to write some improvements in this code.
you don’t need to post multiple times. sum is a completely solved problem basically, and implementation, even in C, is still pretty trivial, so I suggest you compare something slightly more interesting.
used your code and my results show julia hand written is faster than numpy! good exercise for me too
median(py_numpy_bench.times) / 1e6
3.498948
median(j_bench_hand.times) / 1e6
3.057931
Yes, a naive hand-written sum in Julia is faster than the built-in one. But it is less precise (for floats), the built-in sum uses pair-wise summation.