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.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.1Nuitka #7 3.671.0869,208741  87% 82% 91% 83%
1.1Nuitka #7 3.711.0873,448741  87% 96% 89% 87%
1.1Nuitka #7 3.661.0866,724741  82% 90% 83% 83%
1.2Nuitka 3.991.1869,712706  83% 82% 91% 83%
1.2Nuitka 4.161.1969,180706  87% 95% 86% 86%
1.2Nuitka 3.921.1969,996706  88% 90% 82% 89%
1.3PyPy 2 3.031.2888,788743  67% 62% 60% 50%
1.3Nuitka #6 4.371.2872,336743  83% 91% 84% 84%
1.3Nuitka #6 4.421.2878,416743  92% 85% 85% 85%
1.3Nuitka #6 4.491.3178,308743  85% 84% 93% 85%
1.3PyPy 2 3.061.3286,804743  58% 54% 67% 72%
1.5Python 3 #7 5.281.4769,124741  93% 91% 88% 90%
1.6PyPy 2 3.081.5387,492743  57% 59% 56% 46%
1.6Python 3 #7 5.301.5767,816741  86% 84% 92% 86%
1.6Python 3 5.601.5767,432706  92% 95% 91% 92%
1.6Python 3 5.631.5861,156706  96% 89% 89% 89%
1.6PyPy 3 #7 3.671.5887,936741  80% 55% 49% 50%
1.6Python 3 #7 5.311.5867,364741  86% 86% 86% 93%
1.6Python 3 5.691.5969,512706  89% 90% 96% 91%
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.7PyPy 3 3.731.6589,024706  49% 77% 58% 48%
1.7PyPy 3 #7 3.631.6688,988741  59% 49% 53% 70%
1.7PyPy 3 #7 3.601.6688,728741  78% 45% 47% 55%
1.7PyPy 3 #6 3.781.6689,304743  51% 50% 52% 86%
1.7PyPy 3 #6 3.821.6891,360743  46% 54% 81% 50%
1.7PyPy 3 3.721.6889,512706  47% 53% 76% 51%
1.7PyPy 3 #6 3.911.6889,628743  85% 51% 46% 52%
1.7PyPy 3 3.721.7188,084706  48% 81% 56% 49%
1.8Python development version #7 6.251.7760,988741  91% 90% 94% 92%
1.8Python development version #7 6.271.7864,596741  92% 90% 91% 94%
1.8Python 3 #6 6.121.7870,776743  87% 88% 95% 87%
1.8Python 3 #6 6.261.7873,496743  88% 87% 93% 87%
1.8Python 3 #6 6.221.7873,140743  88% 92% 86% 87%
1.8Python development version #7 6.261.7865,268741  90% 89% 89% 88%
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 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