thread-ring benchmark N=50,000,000

Each chart bar shows how many times more Memory, one ↓ thread-ring program used, compared to the program that used least Memory.

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.

    sortsort sort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0OCaml #2 161.60161.701,008350  1% 1% 1% 100%
2.1Go #5 14.6714.672,080405  1% 0% 1% 100%
4.3OCaml 6 min6 min4,380282  0% 0% 0% 100%
5.4C gcc #2 142.28142.365,484575  1% 1% 0% 100%
6.6C++ g++ 186.18186.276,676636  1% 0% 0% 100%
7.2Haskell GHC 7.227.237,272306  1% 0% 1% 100%
7.3C++ g++ #2 139.24139.307,360588  1% 1% 0% 100%
7.4C gcc 139.85139.917,424487  1% 1% 0% 100%
7.4OCaml #3 162.44162.547,444296  1% 1% 1% 100%
9.6C gcc #3 163.72163.809,684916  100% 0% 2% 1%
9.8Python 3 #2 205.35205.489,844288  1% 1% 0% 100%
11C++ g++ #4 8.678.6810,812572  0% 0% 1% 100%
11C++ g++ #5 8.148.1510,888652  1% 1% 0% 100%
17Erlang HiPE #2 10.7710.7817,076273  1% 1% 0% 100%
20Erlang HiPE #3 10.8110.8219,744465  1% 0% 0% 100%
20Ada 2005 GNAT #4 184.48184.5819,892960  1% 0% 0% 100%
20Ada 2005 GNAT #2 281.52281.6820,060560  1% 1% 0% 100%
20Ada 2005 GNAT #6 12.4312.4520,2161015  1% 0% 0% 100%
21Ada 2005 GNAT 5 min5 min21,616602  1% 1% 0% 100%
22Ada 2005 GNAT #3 186.42186.5121,692727  1% 1% 0% 100%
31Ruby 246.73246.9031,160331  0% 1% 1% 100%
45Rust 263.80263.9745,236473  1% 1% 0% 100%
52Java  #7 236.46236.5952,452473  1% 1% 1% 100%
54C# Mono 239.94240.0854,108476  1% 1% 0% 100%
54Smalltalk VisualWorks #2 42.7942.8154,916566  0% 1% 1% 100%
68F# Mono #3 17.1417.1668,724329  0% 1% 1% 100%
73F# Mono #2 168.10168.2773,896555  1% 1% 0% 100%
117Racket 116.42116.52118,404262  0% 1% 1% 100%
369Java  #3 248.19248.34371,820530  2% 1% 1% 100%
404Clojure #2 79.2579.36407,564299  1% 0% 1% 100%
406Clojure 81.9282.02409,572348  1% 1% 0% 100%
561Lisp SBCL #2 234.87235.02565,596571  0% 1% 1% 100%
793Erlang HiPE 10.5610.57799,216273  1% 2% 2% 100%
1,637Ruby JRuby 7 min7 min1,650,000342  0% 1% 1% 100%
C gcc #4 Make Error761
C# Mono #2 Timed Out10 min591
Lisp SBCL Timed Out5 min618
Pascal Free Pascal Make Error523
Perl #3 Failed489
Perl Failed353
Ruby #2 Bad Output215
Ruby JRuby #2 Failed228
Scala Failed296
"wrong" (different) algorithm / less comparable programs
1.3Lua #3 15.2215.221,272264
5.6Python 3 #3 10.2410.245,612270
11C++ g++ #3 8.628.6310,904726
20Ada 2005 GNAT #5 0.470.4919,9721476
51F# Mono #4 1.891.9051,476267
179Java  #6 0.960.97180,800543
284Java  #2 4.884.88286,768693
295Java  #5 17.4617.48297,192432
367Java  #4 34.1034.15369,956894
missing benchmark programs
Dart No program
Fortran Intel No program
Hack No program
JavaScript V8 No program
Lua 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