binary-trees benchmark N=14

Each chart bar shows how many times slower, one ↓ binary-trees 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.0Cython 3.270.9865,912706  94% 83% 86% 84%
1.0Cython 3.270.9859,776706  86% 89% 84% 87%
1.0Cython 3.310.9866,396706  86% 91% 88% 87%
1.0PyPy 2 2.640.99320,868743  71% 78% 72% 69%
1.0PyPy 2 2.540.99320,848743  64% 72% 76% 64%
1.0Pyston 2.881.00174,876743  72% 68% 70% 90%
1.0Pyston 2.881.00169,920743  68% 68% 88% 70%
1.0Pyston 2.941.02191,356743  77% 75% 66% 76%
1.1PyPy 3 #7 2.791.11269,188741  63% 60% 75% 59%
1.1PyPy 2 2.891.12319,408743  76% 76% 81% 71%
1.2PyPy 3 2.821.13266,424706  71% 65% 68% 63%
1.2PyPy 3 #7 2.771.13267,396741  67% 54% 61% 69%
1.2PyPy 3 2.831.14267,352706  62% 73% 55% 66%
1.2PyPy 3 2.841.14267,016706  65% 69% 54% 70%
1.2PyPy 3 #7 2.781.15266,692741  62% 62% 60% 78%
1.2PyPy 3 #6 2.941.15266,240743  79% 63% 62% 57%
1.2Nuitka #7 4.111.1873,212741  87% 88% 87% 95%
1.2Nuitka #7 4.041.1873,788741  86% 86% 94% 85%
1.2Nuitka #7 4.081.1870,876741  92% 87% 88% 85%
1.3PyPy 3 #6 2.951.26277,448743  60% 67% 56% 56%
1.3PyPy 3 #6 3.001.28272,388743  58% 63% 63% 68%
1.3Nuitka 4.311.2870,500706  90% 93% 85% 88%
1.3Nuitka 4.451.2974,588706  87% 87% 89% 87%
1.4Nuitka #6 4.741.3873,224743  86% 94% 87% 91%
1.4Nuitka #6 4.781.3972,060743  89% 94% 86% 91%
1.5Python 3 #7 5.281.4765,160741  90% 92% 92% 91%
1.5Python 3 #7 5.391.4768,592741  95% 92% 94% 91%
1.5Python 3 #7 5.291.4766,856741  94% 98% 92% 90%
1.5Nuitka #6 4.851.4970,680743  89% 82% 86% 82%
1.6Nuitka 4.421.5473,156706  93% 92% 96% 96%
1.7Python 2 5.991.6459,252743  91% 98% 91% 92%
1.7Python 2 5.991.6463,748743  93% 92% 96% 91%
1.7Python 2 5.981.6557,668743  96% 92% 91% 92%
1.7Python 3 5.681.6767,680706  93% 91% 87% 90%
1.7Python 3 5.811.6862,448706  92% 92% 86% 86%
1.8Python 3 #6 6.181.7773,412743  91% 92% 88% 93%
1.8Python development version #7 6.251.7760,988741  91% 90% 94% 92%
1.8Python 3 #6 6.191.7871,700743  88% 88% 86% 92%
1.8Python development version #7 6.271.7864,596741  92% 90% 91% 94%
1.8Python development version #7 6.261.7865,268741  90% 89% 89% 88%
1.8Python 3 5.761.8066,152706  90% 83% 90% 84%
1.9Python development version 6.631.8764,316706  90% 95% 88% 87%
1.9Python development version 6.601.8864,452706  92% 91% 92% 90%
1.9Python 3 #6 6.261.8972,488743  86% 90% 86% 86%
1.9Python development version 6.661.8964,708706  94% 92% 96% 88%
2.0Python development version #6 7.271.9868,260743  92% 92% 97% 92%
2.0Numba 7.001.9869,908702  92% 88% 91% 88%
2.0Numba 7.001.9868,076702  89% 91% 88% 90%
2.0Numba 7.021.9976,880702  91% 91% 87% 87%
2.1Python development version #6 7.372.0864,360743  90% 90% 89% 91%
2.1Python development version #6 7.252.0869,508743  88% 88% 88% 93%
missing benchmark programs
Jython No program
IronPython No program
Shedskin No program
MicroPython No program
Grumpy No program

 binary-trees benchmark : Allocate and deallocate many many binary trees

diff program output N = 10 with this 1KB output file to check your program is correct before contributing.

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

Note: this is an adaptation of a benchmark for testing GC so we are interested in the whole tree being allocated before any nodes are GC'd - which probably excludes lazy evaluation.

Note: the left subtrees are heads of the right subtrees, keeping a depth counter in the accessors to avoid duplication is cheating!

Note: the tree should have tree-nodes all the way down, replacing the bottom nodes by some other value is not acceptable; and the bottom nodes should be at depth 0.

Note: these programs are being measured with the default initial heap size - the measurements may be very different with a larger initial heap size or GC tuning.

Please don't implement your own custom memory pool or free list.


The binary-trees benchmark is a simplistic adaptation of Hans Boehm's GCBench, which in turn was adapted from a benchmark by John Ellis and Pete Kovac.

Thanks to Christophe Troestler and Einar Karttunen for help with this benchmark.

Revised BSD license

  Home   Conclusions   License   Play