/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.

     sortsortsort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
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.4Rust 20.865.78180,184779  83% 99% 92% 89%
1.4Lisp SBCL #2 20.9420.97350,456649  0% 1% 100% 1%
1.5Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
1.6Scala #4 24.4414.78397,928494  52% 24% 24% 68%
1.6Java  #2 24.6714.61384,600603  25% 75% 45% 25%
1.6Java  #3 24.8914.48390,708584  34% 73% 38% 30%
1.7C# Mono 25.4725.46180,036654  1% 41% 59% 3%
1.7F# Mono 25.9225.91184,916537  100% 1% 1% 0%
1.8Lisp SBCL 27.2827.33348,988612  1% 0% 1% 100%
2.1Clojure #6 32.0620.23510,328705  23% 74% 40% 24%
2.3Clojure 35.4320.07562,936657  61% 57% 28% 34%
2.4C gcc 36.4636.48131,668706  0% 0% 0% 100%
2.4C++ g++ #2 36.9636.99197,760553  0% 0% 0% 100%
2.5Ada 2005 GNAT 37.9838.01198,176955  1% 0% 0% 100%
2.6Racket #2 39.7339.78396,888640  1% 0% 100% 1%
2.6Pascal Free Pascal 40.7940.82131,380769  0% 0% 100% 0%
2.8OCaml #5 43.7943.86232,164496  0% 0% 0% 100%
3.0Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
3.2Racket 48.7048.77453,596495  1% 1% 100% 0%
3.3Clojure #2 50.5615.08572,800750  88% 82% 85% 82%
3.4Dart 51.8051.52286,616503  1% 1% 100% 1%
3.4Hack #3 52.2352.31582,848480  1% 1% 0% 100%
3.4F# Mono #3 52.6852.67298,228565  96% 1% 1% 4%
3.8Haskell GHC 58.2226.94355,504521  39% 39% 39% 100%
4.0C# Mono #2 61.7861.79616,268650  8% 1% 17% 75%
4.2Haskell GHC #4 64.7320.18813,620612  74% 74% 99% 74%
4.3Hack #2 66.4466.53385,236468  100% 1% 1% 0%
4.4Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
4.5Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
4.6F# Mono #2 70.3670.33349,812515  0% 30% 1% 71%
4.6OCaml #2 71.0025.55201,744784  80% 41% 90% 69%
5.2C gcc #5 79.9421.15219,164963  86% 97% 97% 98%
6.6Ada 2005 GNAT #3 102.1228.78656,6401342  88% 88% 89% 91%
7.2Go 110.79110.83473,004516  0% 55% 0% 46%
7.7Hack 118.01118.14385,232506  0% 100% 0% 1%
7.7Erlang 119.16119.30866,752441  4% 93% 3% 0%
7.9Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
10Ruby JRuby #3 161.45102.931,173,932439  27% 59% 47% 25%
12Ruby 186.27186.40894,240412  1% 100% 1% 1%
12Ruby #2 190.59190.73825,016413  1% 100% 1% 0%
13Ruby #3 194.43194.56684,080439  0% 1% 0% 100%
13Go #5 205.1354.01567,8121000  96% 95% 96% 95%
13Go #4 205.8957.57568,260688  90% 91% 89% 90%
15Go #2 227.1462.12564,340694  92% 91% 93% 92%
23Ruby JRuby 6 min153.951,176,988412  57% 54% 49% 76%
35Python 3 #6 8 min140.741,123,020626  98% 94% 94% 94%
40Perl 10 min10 min480,528448  44% 56% 0% 0%
41PHP #2 10 min10 min1,025,300472  0% 0% 0% 100%
46PHP 11 min11 min1,021,860504  69% 0% 0% 31%
49Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
74PHP #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.2C gcc #2 3.433.4349,540594
0.6C gcc #9 9.422.99229,0321103
0.9C gcc #7 13.714.19155,728850
1.0OCaml 15.1215.16473,644563
1.4Scala 21.5811.94376,052549
2.4Haskell GHC #5 36.9713.76182,616611
4.5Go #6 69.5429.26455,104937
68PHP #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