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 144.21144.3287,148262  0% 0% 1% 100%
1.0Erlang HiPE 9.709.71534,424273  0% 1% 1% 100%
1.1OCaml 6 min6 min14,212282  0% 0% 0% 100%
1.1Python 3 #2 212.64212.789,832288  0% 1% 1% 100%
1.1OCaml #3 152.05152.165,540296  0% 0% 0% 100%
1.1Clojure #2 78.4678.56412,804299  1% 1% 1% 100%
1.2Haskell GHC 7.137.143,220306  0% 1% 1% 100%
1.3F# Mono #3 16.3916.4045,140329  1% 1% 1% 100%
1.3Ruby 247.18247.3419,792331  1% 0% 1% 100%
1.3Ruby JRuby 7 min7 min646,108342  0% 1% 1% 100%
1.3Rust 225.71225.8741,712342  1% 1% 1% 100%
1.3Clojure 84.5384.64410,660348  1% 1% 0% 100%
1.3OCaml #2 152.51152.621,052350  0% 0% 0% 100%
1.5Go #5 11.3511.353,148405  1% 0% 1% 100%
1.8Java  #7 220.79220.9447,644473  1% 1% 1% 100%
1.8C# Mono 229.34229.5032,076476  0% 0% 1% 100%
1.9C gcc 214.59214.756,584487  1% 1% 1% 100%
2.0Java  #3 228.30228.45365,860530  0% 1% 1% 100%
2.1Ada 2005 GNAT #2 7 min7 min17,788560  1% 1% 0% 100%
2.2Smalltalk VisualWorks #2 42.9242.9543,644566  0% 0% 0% 100%
2.2Lisp SBCL #2 5 min5 min447,620571  1% 1% 1% 100%
2.2C++ g++ #4 9.239.249,448572  1% 0% 1% 100%
2.2C gcc #2 215.93216.094,608575  0% 1% 0% 100%
2.2C++ g++ #2 213.08213.226,588588  0% 1% 1% 100%
2.3C# Mono #2 5 min5 min39,252591  0% 1% 1% 100%
2.3Ada 2005 GNAT 10 min10 min19,800602  1% 0% 1% 100%
2.4C++ g++ 5 min5 min5,328636  0% 1% 1% 100%
2.5C++ g++ #5 8.488.499,444652  0% 1% 0% 100%
2.8Ada 2005 GNAT #3 291.26291.4618,020727  1% 0% 0% 100%
2.9C gcc #4 212.43212.568,704761  0% 1% 1% 100%
3.5C gcc #3 273.09273.288,612916  100% 1% 1% 0%
3.7Ada 2005 GNAT #4 293.85294.0518,020960  1% 0% 0% 100%
3.9Ada 2005 GNAT #6 10.4210.4319,6081015  0% 3% 2% 100%
F# Mono #2 Failed555
Lisp SBCL Timed Out10 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.0Lua #3 17.4417.451,540264
1.0F# Mono #4 1.851.8528,784267
1.0Python 3 #3 10.1110.125,596270
1.6Java  #5 18.7118.73288,932432
2.1Java  #6 0.940.95204,796543
2.6Java  #2 4.844.85280,396693
2.8C++ g++ #3 9.269.279,444726
3.4Java  #4 39.2339.26364,488894
5.6Ada 2005 GNAT #5 0.490.5017,7761476
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