Comparing Sum function from multiple languages

Hello there.

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.

Here is the plot and the 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.

1 Like

it’s been a very good exercise though :wink:

1 Like

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
median(j_bench_hand.times) / 1e6

1 Like

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.

1 Like