binary-trees benchmark N=20

Each chart bar shows how many times more Memory, one ↓ binary-trees program used, compared to the program that used least Memory.

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.

    sortsort sort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0Pascal Free Pascal 33.1933.2165,836769  1% 1% 1% 100%
1.0C gcc 34.4034.4266,784706  100% 0% 0% 0%
1.2Rust 13.703.6580,188791  89% 96% 95% 99%
1.5Ada 2005 GNAT 42.9743.00101,240955  1% 1% 100% 0%
1.6OCaml #2 38.4114.41102,344784  77% 33% 100% 60%
1.6C gcc #3 9.682.97105,024906  93% 77% 87% 72%
1.6Ada 2005 GNAT #4 15.114.98107,3402167  72% 93% 67% 75%
1.7Ada 2005 GNAT #5 15.144.99113,6122167  70% 69% 93% 76%
1.7C gcc #5 128.0948.80113,984963  52% 61% 72% 80%
1.7Ruby #4 194.22194.32114,320402  1% 99% 0% 2%
1.7Ruby #5 193.7567.48114,5881123  63% 63% 66% 96%
1.8C# Mono 21.4320.39116,392654  6% 1% 100% 0%
1.9Fortran Intel #2 19.946.57125,0161199  67% 70% 71% 96%
1.9F# Mono 26.4125.13126,808537  19% 83% 1% 4%
2.1OCaml #5 34.4234.46138,072496  0% 1% 1% 100%
2.1Go #8 57.8716.93139,136814  86% 85% 86% 86%
2.3Lisp SBCL 26.5126.54148,944612  0% 0% 0% 100%
2.3Lisp SBCL #2 17.3417.37148,988649  0% 32% 1% 69%
2.3Go #7 85.4885.44149,256567  9% 25% 1% 67%
2.3Go #9 85.0484.98150,388548  37% 1% 63% 0%
2.3F# Mono #3 37.9436.40150,544565  5% 95% 5% 1%
2.3Go 85.1085.04150,552516  1% 0% 100% 1%
2.3Fortran Intel 202.15202.38154,072826  98% 4% 5% 2%
2.4Ruby #3 230.91231.04159,432439  1% 1% 55% 46%
2.7Go #5 96.7024.76175,2401000  98% 98% 98% 98%
2.7Go #4 90.6724.20175,552688  93% 93% 96% 93%
2.7Go #2 90.9024.16176,316694  93% 94% 94% 96%
2.7Haskell GHC 40.9320.77179,716521  33% 33% 100% 33%
2.7C++ g++ #6 16.575.08180,752892  81% 85% 82% 83%
3.1Ruby #2 230.87230.98202,420413  0% 1% 1% 100%
3.1Ruby 233.65233.76202,472412  1% 67% 0% 34%
3.1Dart 24.6023.06205,328503  8% 18% 22% 61%
3.2F# Mono #2 69.0266.03213,092515  58% 5% 1% 42%
3.9Racket #2 27.2427.27255,740640  0% 0% 1% 100%
3.9C# Mono #2 46.3344.62258,624650  1% 47% 1% 57%
4.0C# Mono #3 39.6324.12265,260723  43% 39% 41% 39%
4.2Racket 36.9336.97276,496495  1% 0% 0% 100%
5.0Perl 11 min11 min330,928448  10% 34% 64% 13%
5.0Ada 2005 GNAT #3 123.9036.41331,0801342  86% 84% 86% 85%
6.2Haskell GHC #4 40.4113.66405,572612  67% 99% 67% 66%
7.1Python 3 7 min125.06470,428596  93% 97% 94% 94%
7.4Java  #3 17.9113.03488,716584  29% 64% 16% 30%
7.7Java  #2 19.0313.56505,456603  50% 52% 17% 23%
7.8Java  #5 19.645.88513,180926  95% 79% 87% 76%
7.8Scala #4 19.1613.92513,600494  20% 50% 45% 28%
8.1Clojure #2 32.8810.16531,228750  76% 90% 84% 76%
8.1Clojure 24.1316.72533,772657  30% 31% 51% 34%
8.1Erlang HiPE 33.0433.07534,884441  1% 1% 96% 4%
8.2Clojure #6 34.6926.42540,464705  48% 23% 15% 47%
8.3PHP 9 min9 min546,228504  9% 78% 14% 1%
8.4PHP #2 8 min8 min549,952472  34% 66% 1% 1%
9.4Erlang HiPE #2 46.2612.88617,852499  99% 88% 88% 86%
13Ruby JRuby #3 9 min265.08844,504439  80% 55% 45% 44%
13Ruby JRuby #4 9 min266.94847,496402  49% 44% 67% 66%
13Ruby JRuby 13 min5 min848,244412  52% 53% 79% 68%
13Ruby JRuby #5 22 min5 min848,5561123  95% 96% 96% 96%
15Perl #3 14 min268.791,018,156706  90% 95% 73% 76%
19PHP #3 11 min11 min1,255,012483  1% 23% 54% 24%
C++ g++ #2 Make Error553
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
 C++ g++ #7 Make Error  919
0.4C gcc #2 2.842.8525,948594
1.6C gcc #7 11.823.84104,952850
1.7C gcc #9 5.821.60114,6681103
1.7Haskell GHC #5 28.4911.49114,856611
3.6OCaml 12.3412.36236,300563
4.1Go #6 35.559.77266,868861
5.2Go #3 37.7010.36342,724836
6.2Scala 17.5211.67408,468549
7.1Python 3 #7 383.25101.01466,084613
15PHP #4 313.26162.10955,116945

 binary-trees benchmark : Allocate and deallocate many many binary trees

You can write your own program for this task and contribute to the benchmarks game by following these general instructions.

More specifically:

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