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 5 min256.701,052350  45% 9% 8% 47%
3.0Go #5 11.3311.333,148405  100% 0% 1% 1%
3.7Haskell GHC 11.459.173,896306  100% 9% 8% 8%
4.4C gcc #2 7 min6 min4,608575  32% 24% 24% 31%
5.1C++ g++ 9 min6 min5,328636  35% 34% 32% 32%
5.3OCaml #3 5 min247.815,540296  51% 6% 6% 51%
6.3C gcc 7 min6 min6,584487  32% 24% 23% 30%
6.3C++ g++ #2 7 min6 min6,584588  32% 24% 24% 28%
8.2C gcc #3 271.18271.358,604916  100% 1% 1% 0%
8.3C gcc #4 7 min6 min8,700761  28% 28% 27% 25%
9.0C++ g++ #4 9 min171.319,440572  89% 88% 87% 89%
9.0C++ g++ #5 9 min173.969,440652  87% 85% 85% 87%
9.3Python 3 #2 8 min6 min9,832288  42% 12% 12% 42%
13OCaml 11 min8 min13,940282  42% 18% 17% 42%
17Ada 2005 GNAT #6 186.6246.8517,7721015  100% 100% 100% 100%
17Ada 2005 GNAT #2 13 min9 min18,000560  34% 34% 32% 33%
17Ada 2005 GNAT #3 10 min8 min18,036727  27% 28% 28% 27%
19Ada 2005 GNAT 23 min12 min19,820602  46% 46% 45% 45%
20Ada 2005 GNAT #4 10 min8 min20,780960  17% 38% 39% 17%
26Ruby 8 min7 min27,640331  22% 26% 26% 24%
26Ruby #2 26 min19 min27,652215  28% 29% 30% 30%
40Rust 7 min6 min41,708342  28% 21% 21% 28%
42F# Mono #3 16.5416.5344,368329  64% 35% 2% 1%
44Java  #7 7 min6 min46,352473  26% 20% 21% 28%
46C# Mono 12 min6 min48,224476  46% 44% 43% 42%
46F# Mono #2 13 min5 min48,848555  60% 61% 60% 60%
47C# Mono #2 11 min8 min49,852591  32% 31% 33% 32%
89Racket 162.01162.0493,596262  0% 1% 1% 100%
274Perl 52 min34 min288,772353  38% 38% 33% 33%
348Java  #3 7 min6 min366,028530  23% 24% 25% 24%
383Clojure 123.94110.49403,028348  32% 32% 24% 23%
383Clojure #2 121.56108.63403,420299  32% 32% 23% 22%
508Erlang 38.4138.39534,164273  0% 0% 1% 99%
509Erlang HiPE 39.7439.73535,360273  0% 99% 0% 1%
661Lisp SBCL 9 min7 min695,672618  31% 28% 28% 30%
665Perl #3 13 min10 min699,072489  53% 54% 7% 8%
702Lisp SBCL #2 10 min8 min738,328571  28% 33% 33% 25%
763Ruby JRuby 11 min9 min802,808342  30% 27% 26% 26%
Pascal Free Pascal Make Error523
Ruby JRuby #2 Failed228
Scala Failed296
"wrong" (different) algorithm / less comparable programs
5.3Python 3 #3 10.1210.125,592270
9.0C++ g++ #3 9.309.319,444726
17Ada 2005 GNAT #5 0.520.4917,7761476
27F# Mono #4 1.861.8728,520267
266Java  #6 1.010.93279,884543
267Java  #2 4.934.83280,504693
271Java  #5 18.3516.66285,452432
275Java  #4 35.0232.32289,004894
missing benchmark programs
Dart No program
Fortran Intel No program
Hack 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