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 #3 9.339.35149,132906  4% 0% 1% 100%
1.2Ada 2005 GNAT #5 10.8910.92158,4042167  1% 1% 1% 100%
1.2Ada 2005 GNAT #4 10.9010.92158,3122167  1% 1% 0% 100%
1.4C++ g++ #6 13.1013.11296,288892  1% 1% 1% 100%
2.0Rust 18.9118.94229,288788  1% 1% 1% 100%
2.3Haskell GHC #4 21.6321.66312,868612  0% 0% 1% 100%
2.5Java  #2 22.9622.99448,112603  0% 0% 1% 100%
2.5Java  #3 23.1023.14450,320584  0% 1% 1% 100%
2.5Fortran Intel #2 23.2023.22149,3681199  0% 0% 0% 100%
2.5Scala #4 23.2523.28450,892494  0% 0% 0% 100%
2.5Lisp SBCL #2 23.7323.77310,176649  0% 0% 1% 100%
2.6C# Mono 24.5924.63133,464654  1% 1% 0% 100%
2.7F# Mono 25.0425.08138,316537  1% 1% 0% 100%
2.7Haskell GHC 25.4225.46314,880521  0% 1% 0% 100%
3.0Dart 28.3228.35292,228503  1% 1% 0% 100%
3.3Clojure #6 30.5230.57523,580705  0% 1% 1% 100%
3.3Clojure 31.0231.07569,364657  0% 0% 1% 100%
3.4Lisp SBCL 31.3731.43310,180612  0% 1% 1% 100%
3.6Clojure #2 33.5533.60606,024750  0% 0% 1% 100%
3.9C gcc 36.2536.28131,668706  2% 1% 1% 100%
4.2C++ g++ #2 39.3139.34197,752553  1% 1% 1% 100%
4.2Ada 2005 GNAT 39.3139.35198,172955  1% 0% 0% 100%
4.3Racket #2 39.8439.91397,088640  0% 0% 1% 100%
4.5Pascal Free Pascal 41.6141.65131,376769  1% 1% 1% 100%
4.6JavaScript V8 42.5542.63763,160467  0% 0% 1% 100%
4.7OCaml #5 43.8043.87232,168496  0% 0% 0% 100%
4.8OCaml #2 44.3744.47201,748784  0% 0% 0% 100%
5.0F# Mono #3 47.0747.14347,828565  1% 1% 1% 100%
5.1Fortran Intel 47.9948.02132,032826  3% 0% 0% 100%
5.2Racket 48.8348.91460,076495  0% 1% 1% 100%
5.6Hack #3 52.3152.39582,848480  1% 1% 0% 100%
5.9C# Mono #2 54.8454.92607,156650  1% 1% 1% 100%
6.1Go #8 57.3557.43275,708814  1% 1% 0% 100%
6.1Erlang HiPE #2 57.3557.44647,288499  0% 0% 0% 100%
7.1Hack #2 66.5866.67385,236468  1% 1% 1% 100%
7.3Erlang HiPE 67.6667.77872,752441  0% 0% 0% 100%
7.9F# Mono #2 73.8673.97246,528515  1% 1% 0% 100%
8.4C gcc #5 78.6278.69219,040963  0% 1% 1% 100%
8.7Smalltalk VisualWorks 81.4081.49320,668722  0% 0% 0% 100%
11Ada 2005 GNAT #3 98.5898.67658,6721342  1% 0% 1% 100%
11Go #7 104.05104.19315,704567  1% 1% 1% 100%
11Go #4 105.85106.00362,944688  0% 1% 1% 100%
11Go #2 106.88107.02364,276694  0% 1% 1% 100%
11Go 107.21107.36312,568516  0% 1% 1% 100%
12Go #5 107.42107.57364,9761000  0% 1% 1% 100%
13Hack 117.27117.39385,224506  0% 0% 0% 100%
17Ruby #4 156.88157.05652,544402  1% 1% 1% 100%
17Ruby #5 160.00160.18257,6001123  1% 1% 0% 100%
20Ruby 184.49184.65825,196412  1% 1% 0% 100%
20Ruby #2 190.06190.21825,196413  1% 1% 0% 100%
21Ruby #3 194.55194.701,022,388439  1% 1% 0% 100%
23Ruby JRuby #4 210.06210.331,017,112402  1% 1% 1% 100%
24Ruby JRuby #3 223.32223.571,011,384439  0% 1% 0% 100%
49Lua #2 7 min7 min1,776,376446  0% 0% 0% 100%
51Python 3 #6 7 min8 min1,123,040626  0% 1% 1% 100%
63Perl 9 min9 min480,396448  0% 0% 0% 100%
69PHP #2 10 min10 min1,025,292472  0% 0% 0% 100%
76PHP 11 min11 min1,021,852504  0% 0% 0% 100%
153Ruby JRuby #5 23 min23 min1,054,9641123  1% 1% 1% 100%
Perl #3 Failed706
PHP #3 Failed483
Racket #3 Bad Output877
Ruby JRuby Failed412
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.4C gcc #2 3.683.6949,540594
0.8C gcc #9 7.307.31229,4241103
1.0C gcc #7 9.549.56149,204850
1.1C++ g++ #7 10.6210.63100,488919
1.6OCaml 14.8214.85485,392563
2.3Scala 21.3721.40391,564549
2.4Haskell GHC #5 22.5822.60204,336611
3.3Go #3 30.6930.74623,560836
5.5Go #6 51.6451.71406,584937
88PHP #4 821.05821.931,809,632945
 Lua #3 Timed Out  477

 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