Ring benchmark: Erlang vs Go

Nice, running ring_benchmark2 with this setup (and a makefile to auto-compile and run it all):

❯ make
erl -noinput -boot no_dot_erlang -eval 'io:write(ring_benchmark2:run(100, 100000)),io:nl(),erlang:halt().'
5875749
erl -noinput -boot no_dot_erlang -eval 'io:write(ring_benchmark:run(100, 100000)),io:nl(),erlang:halt().'
6443983
./go-ring2 -m=100 -n=100000
4.931530382s
./go-ring -m=100 -n=100000
7.050652335s
./target/release/ring_rs_greenthreads -m100 -n100000
2.790588133s

It’s about a half second faster than the original erlang one above in the thread!

Hyperfine is nice when you want to benchmark full runs including startup time, but not when you are just testing a part of an algorithm within a program.

Hmm, let’s see what hyperfine thinks of it all though anyway, because startup time is a cost after all, as well is setting up all of the stuff before actually running the test, aaand that took a while, lol, printing it here split by benchmark run set:

❯ hyperfine 'erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark2:run(100, 100000)),io:nl(),erlang:halt()."' 'erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark:run(100, 100000)),io:nl(),erlang:halt()."' './go-ring2 -m=100 -n=100000' './go-ring -m=100 -n=100000' './target/release/ring_rs_greenthreads -m100 -n100000'
Benchmark 1: erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark2:run(100, 100000)),io:nl(),erlang:halt()."
  Time (mean ± σ):      6.738 s ±  0.143 s    [User: 8.655 s, System: 1.583 s]
  Range (min … max):    6.569 s …  6.967 s    10 runs
Benchmark 2: erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark:run(100, 100000)),io:nl(),erlang:halt()."
  Time (mean ± σ):      7.057 s ±  0.114 s    [User: 9.352 s, System: 1.904 s]
  Range (min … max):    6.844 s …  7.177 s    10 runs
Benchmark 3: ./go-ring2 -m=100 -n=100000
  Time (mean ± σ):      5.119 s ±  0.173 s    [User: 6.585 s, System: 0.754 s]
  Range (min … max):    4.927 s …  5.447 s    10 runs
Benchmark 4: ./go-ring -m=100 -n=100000
  Time (mean ± σ):      7.479 s ±  0.168 s    [User: 9.196 s, System: 1.241 s]
  Range (min … max):    7.237 s …  7.720 s    10 runs
Benchmark 5: ./target/release/ring_rs_greenthreads -m100 -n100000
  Time (mean ± σ):      2.959 s ±  0.093 s    [User: 3.248 s, System: 0.681 s]
  Range (min … max):    2.804 s …  3.105 s    10 runs

And complete, the final summary:

Summary
  './target/release/ring_rs_greenthreads -m100 -n100000' ran
    1.73 ± 0.08 times faster than './go-ring2 -m=100 -n=100000'
    2.28 ± 0.09 times faster than 'erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark2:run(100, 100000)),io:nl(),erlang:halt()."'
    2.38 ± 0.08 times faster than 'erl -noinput -boot no_dot_erlang -eval "io:write(ring_benchmark:run(100, 100000)),io:nl(),erlang:halt()."'
    2.53 ± 0.10 times faster than './go-ring -m=100 -n=100000'
4 Likes

Please take in consideration to make a PR in this repo:

Thanks

4 Likes