thread-ring benchmark N=5,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.

    sort sortsort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0PyPy 3 0.170.17?407  0% 100% 6% 0%
1.0PyPy 3 #3 0.170.17?407  0% 0% 0% 94%
1.0PyPy 3 #3 0.170.17?407  100% 0% 0% 0%
1.0PyPy 3 0.170.17?407  0% 100% 0% 0%
1.1PyPy 3 #3 0.180.18?407  100% 0% 0% 0%
1.1PyPy 2 0.190.19?407  0% 100% 5% 0%
1.1PyPy 2 0.190.19?407  0% 0% 100% 5%
1.1PyPy 3 0.190.19?407  47% 60% 5% 0%
1.2PyPy 2 0.200.20?407  5% 50% 47% 0%
2.1Cython 0.350.351,764407  3% 100% 3% 0%
2.1Cython 0.360.361,816407  0% 100% 0% 3%
2.2Cython 0.380.381,856407  3% 97% 0% 10%
4.5Python 2 0.770.776,432407  4% 0% 4% 100%
4.6Python 2 0.770.786,424407  4% 5% 100% 4%
4.6Python 2 0.780.796,444407  7% 99% 8% 3%
4.8Python 3 #3 0.810.818,972407  0% 2% 0% 100%
4.8Python 3 0.810.828,924407  0% 0% 3% 96%
4.8Python 3 #3 0.820.829,068407  99% 0% 2% 1%
4.9Python 3 0.830.839,100407  100% 1% 1% 0%
4.9Python 3 0.830.839,004407  2% 0% 100% 0%
5.1Python 3 #3 0.860.869,072407  0% 100% 0% 2%
5.1Nuitka 0.860.8617,888407  99% 1% 6% 2%
5.1Nuitka #3 0.860.8617,816407  100% 0% 0% 2%
5.2MicroPython #3 0.880.882,264407  1% 100% 1% 1%
5.2MicroPython 0.880.882,300407  3% 1% 100% 1%
5.2MicroPython 0.890.892,356407  2% 1% 100% 0%
5.2MicroPython #3 0.890.892,356407  3% 2% 100% 0%
5.3MicroPython 0.900.902,448407  2% 2% 2% 100%
5.4MicroPython #3 0.910.922,296407  9% 7% 3% 100%
5.4Nuitka #3 0.920.9217,860407  0% 100% 1% 1%
5.6Nuitka 0.950.9517,784407  100% 1% 0% 1%
5.6Python development version #3 0.950.957,928407  22% 4% 79% 2%
5.6Nuitka 0.950.9517,840407  100% 1% 2% 1%
5.6Python development version #3 0.950.957,984407  5% 100% 1% 2%
5.6Python development version 0.950.958,072407  100% 1% 1% 1%
5.6Nuitka #3 0.950.9517,852407  100% 2% 3% 2%
5.6Python development version 0.950.968,020407  23% 3% 77% 4%
5.6Python development version #3 0.960.967,888407  3% 3% 100% 3%
5.7Python development version 0.970.977,984407  10% 3% 4% 100%
6.2Pyston 1.051.0529,760407  3% 0% 99% 1%
6.2Pyston 1.051.0538,048407  100% 0% 4% 1%
6.2Pyston 1.051.0629,900407  2% 11% 100% 3%
13IronPython 2.272.1558,432407  2% 71% 2% 31%
16IronPython 2.382.6558,424407  4% 3% 58% 27%
16IronPython 2.312.6556,692407  82% 0% 3% 2%
17Grumpy 3.032.858,280407  28% 29% 26% 27%
17Grumpy 3.072.898,516407  27% 27% 25% 32%
17Grumpy 3.072.898,572407  29% 27% 34% 23%
22Jython 8.613.79286,184407  56% 59% 63% 56%
23Jython 8.453.85288,836407  71% 58% 47% 55%
23Jython 8.723.94285,108407  55% 56% 73% 54%
116MicroPython #2 24.4019.646,216448  25% 29% 27% 29%
121MicroPython #2 25.7420.646,368448  28% 30% 22% 27%
127PyPy 3 #2 28.0521.6568,508448  35% 31% 24% 23%
129MicroPython #2 27.0721.866,328448  27% 27% 30% 26%
130PyPy 3 #2 28.3422.1267,816448  24% 31% 27% 29%
131PyPy 3 #2 28.5722.3368,428448  24% 26% 32% 28%
135Nuitka #2 29.9322.9915,820448  30% 31% 26% 27%
135Nuitka #2 30.2723.0315,824448  31% 31% 27% 25%
136Nuitka #2 30.3923.1915,756448  23% 35% 28% 28%
137Python development version #2 29.8423.2713,156448  33% 31% 27% 30%
142Python development version #2 31.3724.0912,996448  17% 51% 9% 48%
145Python development version #2 31.3024.5913,004448  36% 42% 34% 34%
152Python 3 #2 33.0325.9214,384448  34% 29% 26% 21%
155Python 3 #2 33.7626.3014,552448  32% 27% 31% 20%
156Python 3 #2 33.8226.4414,276448  37% 23% 26% 25%
missing benchmark programs
Shedskin No program
Numba No program

 thread-ring benchmark : Switch from thread to thread passing one token

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