thread-ring benchmark N=50,000,000

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

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.0Racket 163.53163.6151,060262  0% 1% 1% 100%
1.0Erlang HiPE 11.0719.08268,880273  0% 0% 0% 59%
1.1OCaml 5 min5 min8,600282  0% 0% 0% 100%
1.1Python 3 #2 212.95213.066,260288  0% 1% 0% 100%
1.1OCaml #3 151.64151.713,004296  0% 0% 0% 100%
1.1Clojure #2 83.5883.67383,832299  0% 1% 1% 100%
1.2Haskell GHC 7.007.003,040306  1% 1% 1% 100%
1.3F# Mono #3 19.7019.7232,392329  0% 1% 1% 100%
1.3Ruby 259.66259.8015,576331  0% 1% 1% 100%
1.3Rust 227.73227.8439,480342  1% 1% 0% 100%
1.3Clojure 86.8986.98385,508348  1% 1% 1% 100%
1.3OCaml #2 154.76154.84640350  0% 0% 0% 100%
1.5Go #5 11.2211.232,884405  1% 0% 0% 100%
1.8Java  #7 253.80253.9122,712473  1% 1% 0% 100%
1.8C# Mono 260.16260.2921,008476  0% 1% 1% 100%
1.9C gcc 136.42136.477,504487  0% 0% 0% 100%
2.0Java  #3 256.69256.82277,448530  1% 1% 0% 100%
2.1F# Mono #2 142.82142.9141,764555  0% 1% 1% 100%
2.1Ada 2005 GNAT #2 5 min5 min16,864560  0% 1% 1% 100%
2.2Smalltalk VisualWorks #2 48.8248.8422,480566  0% 0% 0% 100%
2.2Lisp SBCL #2 261.66261.77884,476571  1% 1% 1% 100%
2.2C++ g++ #4 9.189.196,604572  1% 1% 0% 100%
2.2C gcc #2 130.95131.002,424575  1% 1% 1% 100%
2.2C++ g++ #2 136.06136.127,508588  1% 1% 0% 100%
2.3C# Mono #2 6 min6 min23,624591  0% 1% 1% 100%
2.3Ada 2005 GNAT 5 min5 min14,744602  0% 1% 1% 100%
2.4C++ g++ 175.50175.573,016636  1% 1% 1% 100%
2.5C++ g++ #5 8.848.856,604652  1% 1% 0% 100%
2.8Ada 2005 GNAT #3 182.70182.7714,812727  0% 1% 1% 100%
3.5C gcc #3 155.85155.912,596916  100% 1% 1% 1%
3.7Ada 2005 GNAT #4 182.56182.6314,828960  1% 1% 1% 100%
3.9Ada 2005 GNAT #6 15.5415.5614,8281015  0% 1% 1% 100%
C CINT Failed487
C CINT #2 Failed575
C gcc #4 Timed Out5 min761
Lisp SBCL Timed Out10 min618
Pascal Free Pascal Make Error523
Perl #3 Failed489
Perl Failed353
Ruby #2 Bad Output215
Ruby JRuby #2 Failed228
Ruby JRuby Failed342
Scala Failed296
"wrong" (different) algorithm / less comparable programs
1.0Lua #3 19.2419.251,080264
1.0F# Mono #4 2.132.1422,884267
1.0Python 3 #3 11.5311.534,412270
1.6Java  #5 19.3119.32261,092432
2.1Java  #6 1.251.26281,844543
2.6Java  #2 5.355.36267,052693
2.8C++ g++ #3 9.169.174,556726
3.4Java  #4 36.5436.56329,752894
5.6Ada 2005 GNAT #5 0.540.5514,8281476
missing benchmark programs
Dart No program
Fortran Intel 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