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.368.505,500306  4% 100% 3% 4%
1.6Go #5 15.1615.161,892405  1% 1% 1% 100%
2.1F# Mono #3 19.6719.6954,204329  0% 1% 100% 1%
5.0Erlang HiPE 47.2247.23534,148273  0% 1% 99% 1%
11Racket 103.52103.5353,068262  1% 9% 91% 0%
13Clojure #2 126.29112.09388,300299  28% 27% 28% 28%
13Clojure 126.30112.80388,016348  28% 27% 28% 26%
27Ada 2005 GNAT #6 251.9766.0217,0681015  96% 96% 96% 97%
39C++ g++ #4 6 min112.803,752572  81% 81% 80% 80%
41C++ g++ #5 6 min118.943,712652  82% 82% 80% 80%
41OCaml #3 6 min296.603,000296  25% 24% 23% 25%
42OCaml #2 6 min5 min660350  21% 22% 22% 21%
45C++ g++ #2 6 min5 min8,328588  20% 20% 30% 30%
47C gcc #2 7 min5 min3,228575  24% 22% 21% 23%
50Lisp SBCL 7 min6 min709,696618  21% 33% 31% 21%
50C++ g++ 7 min5 min4,184636  29% 28% 28% 27%
54Python 3 #2 8 min6 min6,256288  37% 14% 14% 37%
55Ada 2005 GNAT #4 8 min6 min18,804960  27% 25% 24% 26%
56Ada 2005 GNAT #3 8 min6 min16,936727  25% 27% 26% 25%
58Lisp SBCL #2 8 min6 min1,088,856571  31% 28% 27% 30%
58Java  #3 8 min6 min371,116530  31% 30% 24% 23%
61Java  #7 9 min6 min31,880473  27% 26% 28% 27%
61Rust 9 min7 min59,324473  29% 25% 26% 29%
62Ruby 9 min8 min20,784331  26% 28% 27% 22%
75Ada 2005 GNAT #2 11 min7 min16,860560  33% 30% 30% 32%
77OCaml 11 min9 min2,052282  27% 28% 28% 27%
82F# Mono #2 12 min286.7661,860555  67% 67% 67% 68%
83Perl #3 12 min10 min433,276489  24% 30% 30% 24%
96Ada 2005 GNAT 14 min8 min17,164602  43% 40% 39% 43%
109C# Mono 17 min8 min39,824476  46% 43% 40% 44%
205Ruby #2 31 min25 min21,492215  23% 31% 35% 24%
450C# Mono #2 1h 10 min26 min44,348591  67% 66% 64% 66%
C gcc #3 Failed916
C gcc Make Error487
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.600.5817,0881476
0.2Java  #6 1.481.49290,444543
0.2F# Mono #4 2.042.0445,516267
0.6Java  #2 5.455.39278,112693
1.1C++ g++ #3 9.879.885,928726
1.2Python 3 #3 11.5811.594,396270
1.6Java  #5 15.1514.00294,304432
3.2Java  #4 29.7027.73294,068894
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