/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++ g++ #7 15.404.77132,948919  94% 58% 87% 87%
1.2Ada 2005 GNAT #4 18.135.50163,7442167  94% 88% 73% 80%
1.2Ada 2005 GNAT #5 17.885.55162,4242167  94% 74% 73% 86%
1.2Rust 20.865.78180,184779  83% 99% 92% 89%
1.6Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
3.0Java  #3 24.8914.48390,708584  34% 73% 38% 30%
3.1Java  #2 24.6714.61384,600603  25% 75% 45% 25%
3.1Scala #4 24.4414.78397,928494  52% 24% 24% 68%
3.2Clojure #2 50.5615.08572,800750  88% 82% 85% 82%
4.2Clojure 35.4320.07562,936657  61% 57% 28% 34%
4.2Haskell GHC #4 64.7320.18813,620612  74% 74% 99% 74%
4.2Clojure #6 32.0620.23510,328705  23% 74% 40% 24%
4.4Lisp SBCL #2 20.9420.97350,456649  0% 1% 100% 1%
4.4C gcc #5 79.9421.15219,164963  86% 97% 97% 98%
5.3C# Mono 25.4725.46180,036654  1% 41% 59% 3%
5.4OCaml #2 71.0025.55201,744784  80% 41% 90% 69%
5.4F# Mono 25.9225.91184,916537  100% 1% 1% 0%
5.7Haskell GHC 58.2226.94355,504521  39% 39% 39% 100%
5.7Lisp SBCL 27.2827.33348,988612  1% 0% 1% 100%
5.9Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
6.0Ada 2005 GNAT #3 102.1228.78656,6401342  88% 88% 89% 91%
7.1Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
7.7C gcc 36.4636.48131,668706  0% 0% 0% 100%
7.8C++ g++ #2 36.9636.99197,760553  0% 0% 0% 100%
8.0Ada 2005 GNAT 37.9838.01198,176955  1% 0% 0% 100%
8.3Racket #2 39.7339.78396,888640  1% 0% 100% 1%
8.6Pascal Free Pascal 40.7940.82131,380769  0% 0% 100% 0%
9.2OCaml #5 43.7943.86232,164496  0% 0% 0% 100%
9.6Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
10Racket 48.7048.77453,596495  1% 1% 100% 0%
11Dart 51.8051.52286,616503  1% 1% 100% 1%
11Hack #3 52.2352.31582,848480  1% 1% 0% 100%
11F# Mono #3 52.6852.67298,228565  96% 1% 1% 4%
11Go #5 205.1354.01567,8121000  96% 95% 96% 95%
12Go #4 205.8957.57568,260688  90% 91% 89% 90%
13C# Mono #2 61.7861.79616,268650  8% 1% 17% 75%
13Go #2 227.1462.12564,340694  92% 91% 93% 92%
14Hack #2 66.4466.53385,236468  100% 1% 1% 0%
14Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
15F# Mono #2 70.3670.33349,812515  0% 30% 1% 71%
22Ruby JRuby #3 161.45102.931,173,932439  27% 59% 47% 25%
23Go 110.79110.83473,004516  0% 55% 0% 46%
25Hack 118.01118.14385,232506  0% 100% 0% 1%
25Erlang 119.16119.30866,752441  4% 93% 3% 0%
30Python 3 #6 8 min140.741,123,020626  98% 94% 94% 94%
32Ruby JRuby 6 min153.951,176,988412  57% 54% 49% 76%
39Ruby 186.27186.40894,240412  1% 100% 1% 1%
40Ruby #2 190.59190.73825,016413  1% 100% 1% 0%
41Ruby #3 194.43194.56684,080439  0% 1% 0% 100%
44Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
130Perl 10 min10 min480,528448  44% 56% 0% 0%
133PHP #2 10 min10 min1,025,300472  0% 0% 0% 100%
149PHP 11 min11 min1,021,860504  69% 0% 0% 31%
241PHP #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.6C gcc #9 9.422.99229,0321103
0.7C gcc #2 3.433.4349,540594
0.9C gcc #7 13.714.19155,728850
2.5Scala 21.5811.94376,052549
2.9Haskell GHC #5 36.9713.76182,616611
3.2OCaml 15.1215.16473,644563
6.1Go #6 69.5429.26455,104937
113PHP #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