/mobile Handheld Friendly website

 binary-trees benchmark N=20

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

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.

    sortsortsort 
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0Ruby 184.49184.65825,196412  1% 1% 0% 100%
1.0Ruby #2 190.06190.21825,196413  1% 1% 0% 100%
1.1Ruby JRuby #3 223.32223.571,011,384439  0% 1% 0% 100%
1.1Ruby #3 194.55194.701,022,388439  1% 1% 0% 100%
1.1Erlang HiPE 67.6667.77872,752441  0% 0% 0% 100%
1.1Lua #2 7 min7 min1,776,376446  0% 0% 0% 100%
1.1Perl 9 min9 min480,396448  0% 0% 0% 100%
1.1JavaScript V8 46.1846.25584,248467  0% 1% 0% 100%
1.1Hack #2 66.5866.67385,236468  1% 1% 1% 100%
1.1PHP #2 10 min10 min1,025,292472  0% 0% 0% 100%
1.2Hack #3 52.3152.39582,848480  1% 1% 0% 100%
1.2Scala #4 23.2523.28450,892494  0% 0% 0% 100%
1.2Racket 48.8348.91460,076495  0% 1% 1% 100%
1.2OCaml #5 43.8043.87232,168496  0% 0% 0% 100%
1.2Erlang HiPE #2 57.3557.44647,288499  0% 0% 0% 100%
1.2Dart 52.1252.18287,708503  0% 0% 1% 100%
1.2PHP 11 min11 min1,021,852504  0% 0% 0% 100%
1.2Hack 117.27117.39385,224506  0% 0% 0% 100%
1.3F# Mono #2 70.3070.38349,796515  0% 0% 0% 100%
1.3Go 111.09111.22479,796516  1% 1% 1% 100%
1.3Haskell GHC 25.4225.46314,880521  0% 1% 0% 100%
1.3F# Mono 25.8625.89184,920537  0% 0% 1% 100%
1.3C++ g++ #2 36.8836.91197,760553  0% 1% 1% 100%
1.4F# Mono #3 52.5752.64298,232565  0% 1% 1% 100%
1.4Java  #3 23.1023.14450,320584  0% 1% 1% 100%
1.5Java  #2 22.9622.99448,112603  0% 0% 1% 100%
1.5Lisp SBCL 27.3127.36348,984612  0% 0% 1% 100%
1.5Haskell GHC #4 21.6321.66312,868612  0% 0% 1% 100%
1.5Python 3 #6 7 min8 min1,123,040626  0% 1% 1% 100%
1.6Racket #2 39.8439.91397,088640  0% 0% 1% 100%
1.6Lisp SBCL #2 21.0321.07350,460649  1% 0% 0% 100%
1.6C# Mono #2 61.8061.87616,256650  0% 0% 1% 100%
1.6C# Mono 25.5725.60180,164654  1% 1% 0% 100%
1.6Clojure 31.0231.07569,364657  0% 0% 1% 100%
1.7Go #4 124.65124.79572,472688  0% 1% 1% 100%
1.7Go #2 125.57125.71545,120694  0% 1% 1% 100%
1.7Clojure #6 30.5230.57523,580705  0% 1% 1% 100%
1.7C gcc 36.7036.72131,672706  0% 0% 1% 100%
1.8Smalltalk VisualWorks 81.4081.49320,668722  0% 0% 0% 100%
1.8Clojure #2 33.5533.60606,024750  0% 0% 1% 100%
1.9Pascal Free Pascal 40.9340.95131,384769  1% 0% 0% 100%
1.9Rust 17.9117.95180,456779  0% 0% 1% 100%
1.9OCaml #2 44.3744.47201,748784  0% 0% 0% 100%
2.0Fortran Intel 47.9948.02132,032826  3% 0% 0% 100%
2.2C++ g++ #7 10.6210.63100,496919  0% 0% 1% 100%
2.3Ada 2005 GNAT 38.0238.04198,176955  0% 0% 0% 100%
2.3C gcc #5 78.2678.32219,160963  0% 0% 1% 100%
2.4Go #5 124.25124.39516,0361000  0% 1% 1% 100%
2.9Fortran Intel #2 23.2023.22149,3681199  0% 0% 0% 100%
3.3Ada 2005 GNAT #3 98.3898.45656,6401342  0% 0% 1% 100%
5.3Ada 2005 GNAT #5 10.8610.88158,3962167  0% 0% 1% 100%
5.3Ada 2005 GNAT #4 10.8610.88158,3522167  0% 0% 1% 100%
C++ g++ #6 Make Error892
Perl #3 Failed706
PHP #3 Failed483
Racket #3 Bad Output877
Ruby JRuby Failed412
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
 Lua #3 Timed Out  477
1.3Scala 21.3721.40391,564549
1.4OCaml 14.8214.85485,392563
1.4C gcc #2 3.423.4349,536594
1.5Haskell GHC #5 22.5822.60204,336611
2.1C gcc #7 9.389.38149,140850
2.3Go #6 49.7649.82453,532937
2.3PHP #4 821.05821.931,809,632945
2.7C gcc #9 7.257.27229,0281103

 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