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 9.909.053,500306  100% 3% 4% 3%
1.5Go #5 15.1615.161,892405  1% 1% 1% 100%
2.0F# Mono #3 19.7919.7932,392329  12% 13% 1% 75%
4.8Erlang HiPE 47.2247.23534,148273  0% 1% 99% 1%
13Clojure #2 126.29112.09388,300299  28% 27% 28% 28%
13Clojure 126.30112.80388,016348  28% 27% 28% 26%
16C gcc #3 155.03155.082,596916  100% 1% 1% 0%
17Racket 169.30169.2848,924262  0% 1% 100% 0%
23Ada 2005 GNAT #6 227.3456.9512,7721015  100% 100% 100% 100%
35C gcc 5 min277.547,504487  28% 31% 31% 30%
35C++ g++ #2 5 min288.547,512588  21% 20% 24% 24%
35C gcc #2 5 min294.272,424575  25% 19% 19% 25%
38OCaml #3 6 min271.733,004296  44% 10% 10% 45%
39OCaml #2 6 min288.47692350  5% 51% 50% 5%
41C++ g++ 6 min296.053,016636  30% 29% 24% 24%
44Ada 2005 GNAT #4 7 min5 min14,828960  16% 35% 34% 16%
44Ada 2005 GNAT #3 7 min5 min12,776727  5% 48% 49% 5%
47Lisp SBCL 7 min5 min980,592618  22% 32% 30% 23%
50Java  #7 8 min6 min29,440473  25% 26% 23% 26%
50Rust 8 min6 min39,480342  19% 18% 34% 33%
50Java  #3 8 min6 min366,984530  24% 24% 26% 27%
51C++ g++ #4 8 min147.216,604572  89% 89% 88% 88%
51Python 3 #2 8 min6 min6,268288  20% 20% 33% 33%
53C++ g++ #5 8 min155.444,556652  88% 88% 87% 86%
54Lisp SBCL #2 8 min6 min1,013,168571  29% 28% 27% 30%
58Ruby 9 min7 min15,396331  19% 34% 34% 19%
64Ada 2005 GNAT #2 10 min7 min16,832560  31% 28% 28% 31%
70OCaml 11 min8 min7,608282  47% 14% 13% 47%
77F# Mono #2 12 min275.9741,676555  70% 69% 69% 70%
79C# Mono #2 13 min9 min23,628591  34% 33% 32% 30%
89Perl #3 14 min11 min421,420489  55% 6% 6% 56%
93C# Mono 15 min7 min20,456476  46% 46% 46% 45%
104Ada 2005 GNAT 17 min9 min16,812602  40% 40% 39% 40%
193Ruby #2 31 min24 min16,572215  20% 36% 41% 21%
C gcc #4 Timed Out5 min761
Pascal Free Pascal Make Error523
Perl Timed Out1h 00 min353
Ruby JRuby #2 Failed228
Ruby JRuby Failed342
Scala Failed296
"wrong" (different) algorithm / less comparable programs
0.1Ada 2005 GNAT #5 0.580.5514,8281476
0.1Java  #6 1.241.23287,968543
0.2F# Mono #4 2.142.1522,620267
0.5Java  #2 5.445.34263,428693
0.9C++ g++ #3 9.229.236,600726
1.2Python 3 #3 11.4511.454,416270
1.9Java  #5 18.8117.23164,648432
3.6Java  #4 35.2132.58291,216894
missing benchmark programs
Dart No program
Fortran Intel 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