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 10.373.33155,504906  79% 62% 74% 99%
1.6Ada 2005 GNAT #4 17.725.21176,8682167  93% 81% 95% 75%
1.6Ada 2005 GNAT #5 18.005.21162,3242167  82% 97% 77% 94%
1.8Rust 22.055.97228,196788  96% 87% 95% 93%
2.3Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
2.4C++ g++ #6 27.048.03357,812892  58% 97% 91% 94%
4.0Java  #2 18.8413.36511,792603  71% 21% 20% 31%
4.0Java  #3 19.1013.40514,072584  60% 35% 25% 25%
4.1Scala #4 19.0413.50513,176494  16% 30% 76% 20%
4.2Clojure #2 47.0413.93609,300750  83% 87% 89% 81%
5.5Go #8 68.4118.42266,624814  94% 94% 92% 93%
5.7Clojure 30.3119.01611,544657  29% 26% 49% 57%
5.8Clojure #6 27.1119.19608,212705  54% 49% 22% 18%
6.1Haskell GHC #4 64.7320.18813,620612  74% 74% 99% 74%
6.2C gcc #5 78.6520.70220,988963  96% 90% 96% 99%
7.2Lisp SBCL #2 23.7523.79310,176649  1% 100% 1% 1%
7.6C# Mono 25.1325.12135,868654  19% 1% 24% 58%
7.6F# Mono 25.4025.38134,468537  1% 25% 1% 75%
7.7OCaml #2 71.0025.55201,744784  80% 41% 90% 69%
8.1Haskell GHC 58.2226.94355,504521  39% 39% 39% 100%
8.4Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
8.4Ada 2005 GNAT #3 101.1028.07658,6721342  90% 90% 93% 89%
8.4Dart 28.3528.10292,220503  2% 1% 1% 100%
9.4Lisp SBCL 31.3631.42310,180612  1% 1% 2% 100%
10Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
11C gcc 36.3636.39131,668706  1% 1% 1% 100%
12Ada 2005 GNAT 39.0239.06198,168955  0% 1% 100% 1%
12C++ g++ #2 39.3639.40197,748553  0% 1% 100% 1%
12Racket #2 39.7339.78396,888640  1% 0% 100% 1%
12Pascal Free Pascal 40.9140.96131,380769  0% 1% 0% 100%
12Hack #3 41.3641.40511,504480  1% 1% 100% 1%
13OCaml #5 43.7943.86232,164496  0% 0% 0% 100%
13Go #4 172.5444.73362,188688  96% 97% 98% 96%
14Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
14Go #2 180.7346.71362,712694  97% 97% 98% 96%
15Racket 48.7048.77453,596495  1% 1% 100% 0%
15Go #5 181.7149.51358,0401000  93% 93% 93% 91%
15F# Mono #3 50.1750.16349,788565  51% 1% 1% 49%
17C# Mono #2 56.2256.21607,056650  0% 1% 100% 0%
17Ruby #5 169.6857.70257,3881123  65% 97% 67% 67%
21Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
21Hack #2 69.2269.28679,428468  0% 1% 100% 1%
23F# Mono #2 75.7775.74232,836515  3% 53% 45% 1%
31Ruby JRuby #3 161.45102.931,173,932439  27% 59% 47% 25%
31Go #7 104.09104.10314,476567  1% 36% 58% 8%
32Go #9 106.11106.10315,700548  0% 0% 44% 57%
32Go 107.17107.16314,776516  40% 47% 12% 3%
36Hack 118.33118.42628,620506  51% 50% 1% 1%
36Erlang 119.16119.30866,752441  4% 93% 3% 0%
42Python 3 #6 8 min140.741,123,020626  98% 94% 94% 94%
46Ruby JRuby 6 min153.951,176,988412  57% 54% 49% 76%
50Ruby #4 165.89166.03265,052402  0% 0% 100% 1%
58Ruby 193.64193.79472,308412  3% 95% 3% 1%
58Ruby #2 193.86194.01472,292413  1% 0% 100% 1%
59Ruby JRuby #4 8 min197.191,145,000402  58% 72% 78% 57%
60Ruby #3 199.74199.90561,480439  1% 0% 98% 2%
64Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
67Ruby JRuby #5 14 min222.581,202,5481123  95% 95% 96% 96%
186Perl 10 min10 min480,528448  44% 56% 0% 0%
191PHP #2 10 min10 min1,025,300472  0% 0% 0% 100%
213PHP 11 min11 min1,021,860504  69% 0% 0% 31%
345PHP #3 19 min19 min2,380,408483  97% 0% 0% 3%
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.9C gcc #9 10.013.05229,1921103
1.1C gcc #2 3.693.6949,544594
1.3C gcc #7 13.934.24155,264850
1.4C++ g++ #7 15.294.73132,668919
3.2Scala 16.7710.77385,552549
3.3Go #3 41.1811.06629,388836
4.1Haskell GHC #5 36.9713.76182,616611
4.6OCaml 15.1215.16473,644563
8.6Go #6 64.2728.75424,620937
162PHP #4 1053.05539.691,809,628945

 binary-trees benchmark : Allocate and deallocate many many binary trees

You can write your own program for this task and contribute to the benchmarks game by following these general instructions.

More specifically:

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