thread-ring benchmark N=50,000,000

Each chart bar shows how many times slower, one ↓ thread-ring program was, compared to the fastest program.

These are not the only programs that could be written. These are not the only compilers and interpreters. These are not the only programming languages.

Column × shows how many times more each program used compared to the benchmark program that used least.

     sortsortsort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0Haskell GHC 11.729.467,948306  9% 9% 100% 9%
1.3Go #5 14.6614.662,080405  0% 1% 1% 100%
1.5F# Mono #3 17.1517.1766,876329  1% 1% 0% 100%
3.4Erlang #2 39.9639.9131,048273  1% 32% 68% 1%
3.4Erlang #3 39.9739.9422,228465  0% 0% 1% 100%
3.4Erlang HiPE #2 40.3640.3622,700273  1% 2% 1% 97%
3.5Erlang HiPE #3 40.6740.6131,220465  1% 7% 93% 1%
3.5Erlang HiPE 41.0541.05801,964273  97% 1% 3% 2%
7.6Clojure 89.6683.20410,376348  32% 22% 23% 31%
7.7Clojure #2 90.2983.67408,564299  33% 23% 23% 30%
9.4Racket 110.38110.44116,232262  1% 0% 100% 1%
14C gcc #3 163.98164.079,676916  100% 1% 1% 1%
17Ada 2005 GNAT #6 202.4151.8819,8521015  98% 98% 98% 98%
32OCaml #3 6 min5 min5,488296  23% 22% 21% 23%
32OCaml #2 6 min5 min1,012350  27% 18% 19% 26%
34C gcc #4 6 min5 min9,576761  21% 20% 26% 25%
34C gcc #2 6 min5 min5,404575  21% 21% 25% 25%
34C gcc 6 min5 min7,412487  21% 21% 24% 23%
35C++ g++ #2 6 min5 min7,460588  23% 23% 21% 20%
35Lisp SBCL 6 min5 min398,796618  25% 25% 26% 25%
38C++ g++ 7 min5 min6,560636  24% 24% 29% 28%
39Ada 2005 GNAT #4 7 min6 min22,712960  15% 15% 33% 32%
41Ada 2005 GNAT #3 8 min6 min19,788727  24% 24% 24% 23%
41C++ g++ #5 8 min149.1610,816652  83% 83% 81% 81%
41Lisp SBCL #2 8 min6 min384,736571  36% 18% 18% 35%
43C++ g++ #4 8 min153.2110,720572  83% 83% 82% 82%
43Python 3 #2 8 min7 min9,848288  29% 27% 21% 22%
44Rust 8 min6 min61,484473  27% 27% 30% 30%
44Java  #7 8 min6 min52,740473  30% 30% 21% 21%
45Java  #3 8 min6 min389,172530  24% 24% 28% 27%
46Ruby 8 min7 min31,404331  28% 22% 23% 28%
51Ada 2005 GNAT #2 10 min6 min20,076560  29% 29% 30% 30%
60Ruby JRuby 11 min9 min802,808342  30% 27% 26% 26%
61OCaml 11 min10 min5,040282  27% 26% 27% 27%
65Perl #3 12 min10 min732,004489  30% 25% 25% 29%
71Ada 2005 GNAT 13 min7 min22,572602  43% 42% 38% 37%
75F# Mono #2 14 min6 min72,652555  56% 55% 53% 52%
77C# Mono 14 min7 min57,176476  47% 43% 43% 41%
136Ruby #2 26 min19 min31,308215  29% 29% 30% 30%
193Perl 37 min27 min324,236353  35% 34% 32% 32%
376C# Mono #2 1h 13 min28 min61,324591  67% 66% 64% 63%
Erlang Failed273
Pascal Free Pascal Make Error523
Ruby JRuby #2 Failed228
Scala Failed296
"wrong" (different) algorithm / less comparable programs
0.0Ada 2005 GNAT #5 0.510.4920,2961476
0.1Java  #6 1.010.94204,164543
0.2F# Mono #4 1.901.9150,976267
0.4Java  #2 4.974.88287,356693
0.7C++ g++ #3 8.688.6910,964726
0.9Python 3 #3 10.1610.175,608270
1.2Java  #5 14.2813.08292,264432
2.4Java  #4 28.5526.85289,336894
missing benchmark programs
Dart No program
Fortran Intel No program
Hack No program
PHP No program

 thread-ring benchmark : Switch from thread to thread passing one token

You can write your own program for this task and contribute to the benchmarks game by following these general instructions.

More specifically:

diff program output N = 1000 with this output file to check your program is correct before contributing.

Each program should create and keep alive 503 pre-emptive threads, explicity or implicitly linked in a ring, and pass a token between one thread and the next thread at least N times.

We are trying to show the performance of various programming language implementations - so we ask that contributed programs not only give the correct result, but also use the same algorithm to calculate that result.

Each program should

Similar benchmarks are described in Performance Measurements of Threads in Java and Processes in Erlang, 1998; and A Benchmark Test for BCPL Style Coroutines, 2004. (Note: 'Benchmarks that may seem to be concurrent are often sequential. The estone benchmark, for instance, is entirely sequential. So is also the most common implementation of the "ring benchmark'; usually one process is active, while the others wait in a receive statement.') For some language implementations increasing the number of threads quickly results in Death by Concurrency.

Programs may use pre-emptive kernel threads or pre-emptive lightweight threads; but programs that use non pre-emptive threads (coroutines, cooperative threads) and any programs that use custom schedulers, will be listed as interesting alternative implementations. Briefly say what concurrency technique is used in the program header comment.

Revised BSD license

  Home   Conclusions   License   Play