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.050.8767,172706  85% 86% 87% 94%
1.0Cython 3.060.8864,072706  95% 87% 87% 86%
1.0Cython 3.050.8867,052706  90% 91% 87% 84%
1.1Pyston 2.881.00174,876743  72% 68% 70% 90%
1.1Pyston 2.881.00169,920743  68% 68% 88% 70%
1.2Pyston 2.941.02191,356743  77% 75% 66% 76%
1.2Nuitka #7 3.621.0975,148741  85% 87% 93% 86%
1.2Nuitka #7 3.801.0973,404741  87% 86% 87% 93%
1.2Nuitka #7 3.591.0967,128741  82% 81% 85% 89%
1.4Nuitka 3.901.1973,232706  87% 84% 81% 81%
1.4Nuitka 3.911.1969,964706  81% 87% 83% 81%
1.4Nuitka 3.971.1966,988706  85% 86% 92% 83%
1.5PyPy 2 3.031.2888,788743  67% 62% 60% 50%
1.5Nuitka #6 4.481.2978,316743  86% 87% 91% 88%
1.5Nuitka #6 4.331.2977,888743  88% 91% 85% 83%
1.5Nuitka #6 4.341.2969,716743  82% 85% 91% 83%
1.5PyPy 2 3.061.3286,804743  58% 54% 67% 72%
1.7Python 3 #7 5.371.4869,148741  91% 90% 93% 90%
1.7Python 3 #7 5.401.4865,892741  90% 93% 90% 94%
1.7Python 3 #7 5.411.4863,344741  90% 97% 91% 90%
1.8PyPy 2 3.081.5387,492743  57% 59% 56% 46%
1.8Python 3 5.811.5863,332706  93% 91% 94% 92%
1.8Python 3 5.681.5863,520706  95% 89% 89% 89%
1.8Python 3 5.691.5865,580706  89% 89% 91% 94%
1.8PyPy 3 #7 3.671.5887,936741  80% 55% 49% 50%
1.9Python 2 5.991.6459,252743  91% 98% 91% 92%
1.9Python 2 5.991.6463,748743  93% 92% 96% 91%
1.9Python 2 5.981.6557,668743  96% 92% 91% 92%
1.9PyPy 3 3.731.6589,024706  49% 77% 58% 48%
1.9PyPy 3 #7 3.631.6688,988741  59% 49% 53% 70%
1.9PyPy 3 #6 3.781.6689,304743  51% 50% 52% 86%
1.9PyPy 3 #7 3.601.6688,728741  78% 45% 47% 55%
1.9PyPy 3 #6 3.821.6891,360743  46% 54% 81% 50%
1.9PyPy 3 3.721.6889,512706  47% 53% 76% 51%
1.9PyPy 3 #6 3.911.6889,628743  85% 51% 46% 52%
2.0PyPy 3 3.721.7188,084706  48% 81% 56% 49%
2.0Python development version #7 6.251.7760,988741  91% 90% 94% 92%
2.0Python 3 #6 6.381.7875,072743  88% 88% 95% 89%
2.0Python development version #7 6.271.7864,596741  92% 90% 91% 94%
2.0Python 3 #6 6.271.7872,248743  87% 93% 87% 87%
2.0Python development version #7 6.261.7865,268741  90% 89% 89% 88%
2.1Python development version 6.631.8764,316706  90% 95% 88% 87%
2.2Python development version 6.601.8864,452706  92% 91% 92% 90%
2.2Python 3 #6 6.301.8863,512743  87% 83% 83% 86%
2.2Python development version 6.661.8964,708706  94% 92% 96% 88%
2.3Python development version #6 7.271.9868,260743  92% 92% 97% 92%
2.4Python development version #6 7.372.0864,360743  90% 90% 89% 91%
2.4Python development version #6 7.252.0869,508743  88% 88% 88% 93%
3.0Numba 7.112.5866,496702  96% 95% 87% 93%
3.0Numba 7.192.5866,400702  97% 92% 89% 97%
3.2Numba 7.302.7570,488702  95% 89% 86% 94%
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