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.0Pyston 1.920.62169,100743  74% 93% 73% 71%
1.0Pyston 1.950.65169,224743  69% 67% 94% 70%
1.1Cython 1.880.6861,148735  82% 70% 72% 69%
1.2Pyston 1.960.72172,728743  68% 88% 71% 67%
1.2Cython 2.000.7565,352735  67% 70% 65% 83%
1.2Cython 1.980.7668,652735  65% 69% 74% 84%
1.2Nuitka 2.530.7772,584706  83% 83% 83% 93%
1.2Nuitka 2.570.7766,100706  84% 82% 93% 84%
1.2Nuitka 2.520.7771,760706  81% 83% 91% 81%
1.2Nuitka #7 2.380.7872,524741  75% 78% 87% 75%
1.4PyPy 2 1.700.84351,120743  56% 48% 49% 68%
1.4PyPy 2 1.720.8487,340743  50% 69% 48% 50%
1.4Nuitka #7 2.400.8566,524741  83% 71% 67% 71%
1.4Nuitka #7 2.420.8666,372741  71% 70% 85% 69%
1.4Nuitka #6 2.860.8772,896743  92% 84% 82% 85%
1.4PyPy 2 1.770.9087,240743  75% 49% 48% 60%
1.5Nuitka #6 2.880.9375,344743  87% 79% 76% 79%
1.6Nuitka #6 2.910.9774,668743  82% 75% 81% 85%
1.7Python development version #7 3.831.0560,736741  95% 90% 90% 90%
1.7Python 3 3.701.0667,320706  88% 95% 88% 89%
1.7Python 3 #7 3.531.0759,940741  84% 83% 91% 82%
1.8Python 3 3.761.1159,900706  95% 83% 84% 83%
1.8Python development version #7 3.911.1157,176741  97% 85% 85% 85%
1.8PyPy 3 2.151.1289,520706  50% 42% 38% 72%
1.9Numba 3.931.1673,772702  85% 91% 83% 83%
1.9Python 3 #6 4.101.1662,824743  96% 89% 88% 87%
1.9Python 3 #6 4.051.1664,604743  87% 87% 94% 87%
1.9PyPy 3 #6 2.241.1789,216743  41% 43% 38% 77%
1.9Python 3 3.681.1864,940706  86% 83% 82% 86%
1.9Python 2 3.821.1959,484743  81% 91% 82% 80%
1.9Python 2 3.771.1958,912743  91% 82% 83% 88%
1.9Python 2 3.851.2060,452743  79% 87% 86% 80%
1.9Python development version #7 3.921.2062,372741  88% 83% 78% 79%
1.9PyPy 3 #6 2.281.2188,988743  43% 39% 42% 74%
2.0Python 3 #7 3.521.2264,232741  80% 77% 79% 87%
2.0Numba 3.991.2364,276702  78% 78% 79% 90%
2.0Python development version 4.111.2361,960706  83% 80% 81% 94%
2.0Python 3 #6 4.131.2366,360743  85% 83% 94% 84%
2.0Numba 4.001.2463,976702  77% 78% 91% 79%
2.0Python 3 #7 3.571.2566,472741  78% 82% 90% 83%
2.0Python development version #6 4.511.2557,916743  95% 89% 89% 88%
2.0Python development version #6 4.461.2667,100743  87% 89% 93% 89%
2.0PyPy 3 2.321.2689,088706  79% 59% 53% 57%
2.1Python development version 4.051.2859,068706  87% 83% 84% 81%
2.1PyPy 3 #7 2.331.2889,836741  78% 47% 52% 51%
2.1Python development version #6 4.591.2969,196743  93% 86% 92% 87%
2.1PyPy 3 2.301.2988,288706  74% 56% 44% 56%
2.1PyPy 3 #7 2.361.2989,640741  73% 67% 58% 68%
2.1Python development version 4.091.3162,208706  86% 79% 81% 81%
2.2PyPy 3 #7 2.391.3690,252741  67% 61% 82% 68%
2.3PyPy 3 #6 2.601.4188,332743  53% 49% 61% 76%
missing benchmark programs
Jython No program
IronPython No program
Shedskin No program
MicroPython No program
Grumpy No program
Graal 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