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.2PyPy 2 1.880.69313,720743  69% 64% 81% 63%
1.3Pyston 1.960.72172,728743  68% 88% 71% 67%
1.4PyPy 2 1.920.76300,036743  55% 59% 64% 78%
1.4Nuitka 2.570.7665,804706  84% 85% 83% 96%
1.4Nuitka 2.610.7672,056706  85% 93% 84% 83%
1.4Nuitka 2.610.7666,116706  95% 84% 84% 86%
1.4Nuitka #7 2.420.7771,852741  79% 76% 76% 85%
1.4PyPy 2 1.890.79309,528743  63% 55% 71% 57%
1.4Nuitka #7 2.440.8068,212741  78% 74% 88% 74%
1.5Nuitka #7 2.440.8365,144741  72% 72% 89% 74%
1.6Nuitka #6 2.820.8667,000743  80% 82% 91% 81%
1.6Nuitka #6 2.940.8669,260743  85% 83% 92% 82%
1.6Nuitka #6 2.870.8772,432743  83% 87% 81% 87%
1.7PyPy 3 #7 2.270.95325,796741  67% 61% 51% 61%
1.7PyPy 3 2.310.95318,460706  59% 64% 72% 55%
1.8PyPy 3 2.330.98321,700706  59% 52% 56% 75%
1.8PyPy 3 #7 2.270.98324,412741  53% 64% 56% 59%
1.8PyPy 3 #6 2.400.98323,236743  58% 68% 61% 58%
1.8Python 3 #7 3.470.9959,436741  85% 86% 85% 97%
1.8PyPy 3 2.341.01313,168706  47% 59% 73% 53%
1.8PyPy 3 #7 2.361.02331,336741  64% 59% 72% 51%
1.8Python 3 #7 3.471.0259,132741  83% 82% 83% 95%
1.9PyPy 3 #6 2.481.0589,792743  76% 57% 52% 56%
1.9Python development version #7 3.831.0560,736741  95% 90% 90% 90%
1.9Python 3 3.671.0662,592706  85% 87% 85% 92%
1.9Python 3 #7 3.451.0760,856741  82% 81% 86% 83%
1.9Python 3 3.691.0762,100706  84% 94% 83% 84%
2.0Python development version #7 3.911.1157,176741  97% 85% 85% 85%
2.0Python 3 3.761.1461,284706  86% 84% 93% 81%
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 3 #6 3.991.1661,928743  85% 84% 84% 92%
2.1Python 2 3.811.1660,644743  79% 87% 84% 82%
2.1Python 3 #6 4.101.1871,092743  87% 86% 94% 85%
2.2Python development version #7 3.921.2062,372741  88% 83% 78% 79%
2.2Python 3 #6 4.091.2265,184743  80% 81% 80% 94%
2.2Python development version 4.111.2361,960706  83% 80% 81% 94%
2.2Numba 3.991.2364,276702  78% 78% 79% 90%
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 #6 2.921.26331,144743  56% 79% 71% 64%
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.4Python development version 4.091.3162,208706  86% 79% 81% 81%
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