/mobile Handheld Friendly website

 binary-trees benchmark N=20

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.0C gcc #7 12.8612.8799,448850  0% 0% 1% 100%
1.1Ada 2005 GNAT #5 14.6114.63105,6962167  0% 0% 0% 100%
1.1Ada 2005 GNAT #4 14.6114.64105,6922167  0% 0% 0% 100%
1.2Java 7  #2 15.7015.75506,592603  0% 1% 0% 100%
1.2C++ g++ #6 15.8015.82148,440892  1% 0% 0% 100%
1.3Haskell GHC #4 16.4916.51183,532612  0% 0% 1% 100%
1.3Scala #4 16.7116.75507,072494  0% 0% 0% 100%
1.4ATS #3 17.7317.75197,2562143  0% 0% 0% 100%
1.4ATS 17.9817.99132,104926  0% 1% 0% 100%
1.5Java 7  18.9719.01546,3321007  0% 0% 0% 100%
1.6Lisp SBCL #2 20.3920.43227,016649  0% 0% 0% 100%
1.6Haskell GHC 20.8920.91181,396521  0% 0% 0% 100%
1.8Fortran Intel #2 23.7723.7999,6161199  0% 0% 0% 100%
2.1Racket #2 26.8326.87226,564640  1% 0% 0% 100%
2.2Lisp SBCL 28.7928.83227,360612  0% 0% 1% 100%
2.3Clojure 29.3429.37558,896657  0% 0% 0% 100%
2.6C gcc 32.8432.8666,096706  0% 0% 0% 100%
2.6Pascal Free Pascal 33.2533.2765,828769  0% 1% 1% 100%
2.7JavaScript V8 34.6534.70432,784467  0% 0% 0% 100%
2.8OCaml #5 35.7335.77115,688496  0% 0% 0% 100%
2.9OCaml #2 36.7336.80101,016784  0% 0% 0% 100%
2.9Racket 37.5637.62270,132495  2% 0% 0% 100%
3.0C++ g++ #2 38.7138.7399,080553  0% 0% 0% 100%
3.0Clojure #6 38.9538.99560,768705  0% 0% 0% 100%
3.1Ada 2005 GNAT 39.6839.7299,440955  0% 0% 0% 100%
3.3Dart 42.6442.69153,364543  0% 0% 0% 100%
3.7Erlang HiPE #2 47.5747.63338,644499  0% 0% 0% 100%
3.9Erlang HiPE 50.4950.55443,172441  0% 0% 0% 100%
4.8C# Mono 61.5661.6192,200654  0% 0% 0% 100%
5.0F# Mono #3 64.1464.19135,168565  0% 0% 0% 100%
5.1Smalltalk VisualWorks 65.6065.67316,312722  0% 0% 0% 100%
5.9C gcc #5 76.0476.09109,664963  0% 0% 0% 100%
6.1C# Mono #2 78.8378.91244,012650  0% 0% 0% 100%
8.5Go 108.70108.81259,996516  0% 0% 0% 100%
9.1Ada 2005 GNAT #3 116.69116.77328,9761342  0% 0% 0% 100%
9.5Go #5 122.12122.23258,6921000  1% 1% 0% 100%
9.7Go #2 124.48124.60311,428694  0% 0% 0% 100%
9.8Go #4 125.40125.52293,052688  0% 0% 0% 100%
10F# Mono #2 131.68131.79214,548515  0% 0% 0% 100%
13Fortran Intel 173.18173.35153,800826  0% 0% 0% 100%
14Ruby JRuby #3 179.39179.62879,376439  1% 0% 0% 100%
18Ruby 2.0 #3 229.52229.64394,784439  0% 0% 0% 100%
20Ruby JRuby 258.34258.58873,136412  0% 0% 0% 100%
35Lua #2 7 min7 min1,033,624446  0% 14% 4% 100%
39Python 3 #6 8 min8 min685,724626  0% 0% 0% 100%
47Perl 10 min10 min289,324448  0% 0% 0% 100%
51PHP 10 min10 min546,160504  0% 0% 0% 100%
70PHP #3 14 min15 min1,249,392483  0% 0% 0% 100%
Perl #3 Failed706
Racket #3 Bad Output877
Ruby 2.0 Failed412
Ruby 2.0 #2 Failed413
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.2C gcc #2 2.982.9925,148594
0.5C gcc #9 6.206.21114,1001103
1.0OCaml 12.6812.71235,696563
1.1Go #3 14.7514.76107,516872
1.2Scala 15.3015.34389,516549
1.3Haskell GHC #5 17.1517.16103,520611
37Lua #3 477.10477.692,963,916477
missing benchmark programs
C CINT 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