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 1.850.5560,892735  82% 80% 84% 93%
1.1Cython 1.910.6161,456735  74% 94% 74% 74%
1.1Pyston 1.920.62169,100743  74% 93% 73% 71%
1.2Pyston 1.950.65169,224743  69% 67% 94% 70%
1.2Cython 1.870.6760,636735  72% 79% 73% 72%
1.3Pyston 1.960.72172,728743  68% 88% 71% 67%
1.4Nuitka 2.620.7671,700706  86% 87% 88% 90%
1.4Nuitka #7 2.420.7765,064741  87% 81% 80% 79%
1.4Nuitka #7 2.350.7769,768741  80% 78% 76% 85%
1.4Nuitka #7 2.500.8067,856741  91% 78% 79% 81%
1.5Nuitka 2.630.8068,156706  83% 79% 81% 96%
1.6Nuitka 2.630.8766,164706  82% 86% 82% 79%
1.6Nuitka #6 2.850.8966,904743  80% 79% 91% 79%
1.6PyPy 2 2.090.91324,636743  65% 51% 54% 71%
1.7Python 3 #7 3.390.9665,856741  90% 94% 88% 88%
1.7Nuitka #6 2.980.9672,964743  82% 81% 79% 94%
1.7PyPy 2 2.130.9687,280743  61% 51% 54% 63%
1.8PyPy 2 2.191.01322,228743  78% 70% 61% 58%
1.9Python 3 #7 3.461.0460,120741  96% 83% 82% 80%
1.9Python development version #7 3.831.0560,736741  95% 90% 90% 90%
1.9Python 3 3.621.0660,176706  86% 87% 88% 92%
1.9Python 3 #7 3.411.0665,784741  80% 89% 80% 83%
1.9Python 3 3.701.0667,732706  87% 85% 94% 85%
1.9Python 3 3.591.0767,612706  84% 92% 85% 87%
1.9Nuitka #6 2.901.0879,084743  85% 81% 78% 86%
2.0Python development version #7 3.911.1157,176741  97% 85% 85% 85%
2.1Python 2 3.771.1454,152743  82% 81% 82% 90%
2.1Python 2 3.831.1556,040743  83% 82% 81% 93%
2.1Numba 3.931.1673,772702  85% 91% 83% 83%
2.1Python 2 3.811.1660,644743  79% 87% 84% 82%
2.2Python 3 #6 4.081.1970,896743  95% 85% 84% 82%
2.2Python development version #7 3.921.2062,372741  88% 83% 78% 79%
2.2PyPy 3 2.641.2390,144706  57% 78% 41% 43%
2.2Numba 3.991.2364,276702  78% 78% 79% 90%
2.2Python development version 4.111.2361,960706  83% 80% 81% 94%
2.2PyPy 3 #6 2.701.2391,100743  44% 55% 78% 44%
2.2PyPy 3 #6 2.721.2393,488743  46% 48% 43% 82%
2.2PyPy 3 #7 2.671.2492,612741  43% 50% 79% 47%
2.2Numba 4.001.2463,976702  77% 78% 91% 79%
2.3Python development version #6 4.511.2557,916743  95% 89% 89% 88%
2.3Python development version #6 4.461.2667,100743  87% 89% 93% 89%
2.3PyPy 3 2.651.2691,412706  51% 70% 49% 42%
2.3Python 3 #6 4.091.2664,656743  84% 79% 80% 89%
2.3Python development version 4.051.2859,068706  87% 83% 84% 81%
2.3Python development version #6 4.591.2969,196743  93% 86% 92% 87%
2.3PyPy 3 2.711.3089,836706  60% 44% 74% 44%
2.3Python 3 #6 4.121.3070,264743  86% 81% 81% 85%
2.4Python development version 4.091.3162,208706  86% 79% 81% 81%
2.4PyPy 3 #7 2.731.3192,588741  48% 78% 45% 42%
2.4PyPy 3 #6 2.831.3190,684743  45% 44% 90% 48%
2.7PyPy 3 #7 2.731.5091,548741  69% 40% 43% 49%
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