/mobile Handheld Friendly website

 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 40.7940.82131,380769  0% 0% 100% 0%
1.0C gcc 36.4636.48131,668706  0% 0% 0% 100%
1.0Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
1.0C++ g++ #7 15.404.77132,948919  94% 58% 87% 87%
1.2Ada 2005 GNAT #5 17.885.55162,4242167  94% 74% 73% 86%
1.2Ada 2005 GNAT #4 18.135.50163,7442167  94% 88% 73% 80%
1.4C# Mono 25.4725.46180,036654  1% 41% 59% 3%
1.4Rust 20.865.78180,184779  83% 99% 92% 89%
1.4Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
1.4F# Mono 25.9225.91184,916537  100% 1% 1% 0%
1.5C++ g++ #2 36.9636.99197,760553  0% 0% 0% 100%
1.5Ada 2005 GNAT 37.9838.01198,176955  1% 0% 0% 100%
1.5OCaml #2 71.0025.55201,744784  80% 41% 90% 69%
1.7C gcc #5 79.9421.15219,164963  86% 97% 97% 98%
1.8OCaml #5 43.7943.86232,164496  0% 0% 0% 100%
2.2Dart 51.8051.52286,616503  1% 1% 100% 1%
2.3F# Mono #3 52.6852.67298,228565  96% 1% 1% 4%
2.7Lisp SBCL 27.2827.33348,988612  1% 0% 1% 100%
2.7F# Mono #2 70.3670.33349,812515  0% 30% 1% 71%
2.7Lisp SBCL #2 20.9420.97350,456649  0% 1% 100% 1%
2.7Haskell GHC 58.2226.94355,504521  39% 39% 39% 100%
2.9Java  #2 24.6714.61384,600603  25% 75% 45% 25%
2.9Hack 118.01118.14385,232506  0% 100% 0% 1%
2.9Hack #2 66.4466.53385,236468  100% 1% 1% 0%
3.0Java  #3 24.8914.48390,708584  34% 73% 38% 30%
3.0Racket #2 39.7339.78396,888640  1% 0% 100% 1%
3.0Scala #4 24.4414.78397,928494  52% 24% 24% 68%
3.5Racket 48.7048.77453,596495  1% 1% 100% 0%
3.6Go 110.79110.83473,004516  0% 55% 0% 46%
3.7Perl 10 min10 min480,528448  44% 56% 0% 0%
3.9Clojure #6 32.0620.23510,328705  23% 74% 40% 24%
4.3Clojure 35.4320.07562,936657  61% 57% 28% 34%
4.3Go #2 227.1462.12564,340694  92% 91% 93% 92%
4.3Go #5 205.1354.01567,8121000  96% 95% 96% 95%
4.3Go #4 205.8957.57568,260688  90% 91% 89% 90%
4.4Clojure #2 50.5615.08572,800750  88% 82% 85% 82%
4.4Hack #3 52.2352.31582,848480  1% 1% 0% 100%
4.7C# Mono #2 61.7861.79616,268650  8% 1% 17% 75%
5.0Ada 2005 GNAT #3 102.1228.78656,6401342  88% 88% 89% 91%
5.2Ruby #3 194.43194.56684,080439  0% 1% 0% 100%
6.2Haskell GHC #4 64.7320.18813,620612  74% 74% 99% 74%
6.3Ruby #2 190.59190.73825,016413  1% 100% 1% 0%
6.3Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
6.6Erlang 119.16119.30866,752441  4% 93% 3% 0%
6.8Ruby 186.27186.40894,240412  1% 100% 1% 1%
7.3Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
7.8PHP 11 min11 min1,021,860504  69% 0% 0% 31%
7.8PHP #2 10 min10 min1,025,300472  0% 0% 0% 100%
7.8Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
8.5Python 3 #6 8 min140.741,123,020626  98% 94% 94% 94%
8.9Ruby JRuby #3 161.45102.931,173,932439  27% 59% 47% 25%
9.0Ruby JRuby 6 min153.951,176,988412  57% 54% 49% 76%
12Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
18PHP #3 19 min19 min2,380,408483  97% 0% 0% 3%
C++ g++ #6 Make Error892
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.4C gcc #2 3.433.4349,540594
1.2C gcc #7 13.714.19155,728850
1.4Haskell GHC #5 36.9713.76182,616611
1.7C gcc #9 9.422.99229,0321103
2.9Scala 21.5811.94376,052549
3.5Go #6 69.5429.26455,104937
3.6OCaml 15.1215.16473,644563
14PHP #4 1053.05539.691,809,628945

 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