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 7.137.143,220306  0% 1% 1% 100%
1.2C++ g++ #5 8.488.499,444652  0% 1% 0% 100%
1.3C++ g++ #4 9.239.249,448572  1% 0% 1% 100%
1.5Ada 2005 GNAT #6 10.4210.4319,6081015  0% 3% 2% 100%
1.5Erlang HiPE 10.5610.57799,216273  1% 2% 2% 100%
2.1Go #5 14.6714.672,080405  1% 0% 1% 100%
2.3F# Mono #3 16.3916.4045,140329  1% 1% 1% 100%
6.0Smalltalk VisualWorks #2 42.9242.9543,644566  0% 0% 0% 100%
11Clojure #2 78.4678.56412,804299  1% 1% 1% 100%
12Clojure 84.5384.64410,660348  1% 1% 0% 100%
20Racket 144.21144.3287,148262  0% 0% 1% 100%
21OCaml #3 152.05152.165,540296  0% 0% 0% 100%
21OCaml #2 152.51152.621,052350  0% 0% 0% 100%
30C gcc #4 212.43212.568,704761  0% 1% 1% 100%
30Python 3 #2 212.64212.789,832288  0% 1% 1% 100%
30C++ g++ #2 213.08213.226,588588  0% 1% 1% 100%
30C gcc 214.59214.756,584487  1% 1% 1% 100%
30C gcc #2 215.93216.094,608575  0% 1% 0% 100%
31Java  #7 220.79220.9447,644473  1% 1% 1% 100%
32Rust 225.71225.8741,712342  1% 1% 1% 100%
32Java  #3 228.30228.45365,860530  0% 1% 1% 100%
32C# Mono 229.34229.5032,076476  0% 0% 1% 100%
33Lisp SBCL #2 237.23237.351,256,916571  1% 1% 1% 100%
35Ruby 247.18247.3419,792331  1% 0% 1% 100%
38C gcc #3 273.09273.288,612916  100% 1% 1% 0%
41Ada 2005 GNAT #3 291.26291.4618,020727  1% 0% 0% 100%
41Ada 2005 GNAT #4 293.85294.0518,020960  1% 0% 0% 100%
44C++ g++ 5 min5 min5,328636  0% 1% 1% 100%
50C# Mono #2 5 min5 min39,252591  0% 1% 1% 100%
55OCaml 6 min6 min14,212282  0% 0% 0% 100%
63Ada 2005 GNAT #2 7 min7 min17,788560  1% 1% 0% 100%
64Ruby JRuby 7 min7 min1,650,000342  0% 1% 1% 100%
90Ada 2005 GNAT 10 min10 min19,800602  1% 0% 1% 100%
F# Mono #2 Failed555
Lisp SBCL Timed Out30 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
0.1Ada 2005 GNAT #5 0.490.5017,7761476
0.1Java  #6 0.940.95204,796543
0.3F# Mono #4 1.851.8528,784267
0.7Java  #2 4.844.85280,396693
1.3C++ g++ #3 9.269.279,444726
1.4Python 3 #3 10.1110.125,596270
2.4Lua #3 17.4417.451,540264
2.6Java  #5 18.7118.73288,932432
5.5Java  #4 39.2339.26364,488894
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