/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 JRuby 6 min153.951,176,988412  57% 54% 49% 76%
1.0Ruby 186.27186.40894,240412  1% 100% 1% 1%
1.0Ruby #2 190.59190.73825,016413  1% 100% 1% 0%
1.1Ruby JRuby #3 161.45102.931,173,932439  27% 59% 47% 25%
1.1Ruby #3 194.43194.56684,080439  0% 1% 0% 100%
1.1Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
1.1Erlang 119.16119.30866,752441  4% 93% 3% 0%
1.1Perl 10 min10 min480,528448  44% 56% 0% 0%
1.1Hack #2 66.4466.53385,236468  100% 1% 1% 0%
1.1PHP #2 10 min10 min1,025,300472  0% 0% 0% 100%
1.2Hack #3 52.2352.31582,848480  1% 1% 0% 100%
1.2PHP #3 19 min19 min2,380,408483  97% 0% 0% 3%
1.2Scala #4 24.4414.78397,928494  52% 24% 24% 68%
1.2Racket 48.7048.77453,596495  1% 1% 100% 0%
1.2OCaml #5 43.7943.86232,164496  0% 0% 0% 100%
1.2Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
1.2Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
1.2Dart 51.8051.52286,616503  1% 1% 100% 1%
1.2PHP 11 min11 min1,021,860504  69% 0% 0% 31%
1.2Hack 118.01118.14385,232506  0% 100% 0% 1%
1.3F# Mono #2 70.3670.33349,812515  0% 30% 1% 71%
1.3Go 110.79110.83473,004516  0% 55% 0% 46%
1.3Haskell GHC 58.2226.94355,504521  39% 39% 39% 100%
1.3F# Mono 25.9225.91184,916537  100% 1% 1% 0%
1.3C++ g++ #2 36.9636.99197,760553  0% 0% 0% 100%
1.4F# Mono #3 52.6852.67298,228565  96% 1% 1% 4%
1.4Java  #3 24.8914.48390,708584  34% 73% 38% 30%
1.5Java  #2 24.6714.61384,600603  25% 75% 45% 25%
1.5Haskell GHC #4 64.7320.18813,620612  74% 74% 99% 74%
1.5Lisp SBCL 27.2827.33348,988612  1% 0% 1% 100%
1.5Python 3 #6 8 min140.741,123,020626  98% 94% 94% 94%
1.6Racket #2 39.7339.78396,888640  1% 0% 100% 1%
1.6Lisp SBCL #2 20.9420.97350,456649  0% 1% 100% 1%
1.6C# Mono #2 61.7861.79616,268650  8% 1% 17% 75%
1.6C# Mono 25.4725.46180,036654  1% 41% 59% 3%
1.6Clojure 35.4320.07562,936657  61% 57% 28% 34%
1.7Go #4 205.8957.57568,260688  90% 91% 89% 90%
1.7Go #2 227.1462.12564,340694  92% 91% 93% 92%
1.7Clojure #6 32.0620.23510,328705  23% 74% 40% 24%
1.7C gcc 36.4636.48131,668706  0% 0% 0% 100%
1.7Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
1.8Clojure #2 50.5615.08572,800750  88% 82% 85% 82%
1.9Pascal Free Pascal 40.7940.82131,380769  0% 0% 100% 0%
1.9Rust 20.865.78180,184779  83% 99% 92% 89%
1.9OCaml #2 71.0025.55201,744784  80% 41% 90% 69%
2.0Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
2.2C++ g++ #7 15.404.77132,948919  94% 58% 87% 87%
2.3Ada 2005 GNAT 37.9838.01198,176955  1% 0% 0% 100%
2.3C gcc #5 79.9421.15219,164963  86% 97% 97% 98%
2.4Go #5 205.1354.01567,8121000  96% 95% 96% 95%
2.9Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
3.3Ada 2005 GNAT #3 102.1228.78656,6401342  88% 88% 89% 91%
5.3Ada 2005 GNAT #5 17.885.55162,4242167  94% 74% 73% 86%
5.3Ada 2005 GNAT #4 18.135.50163,7442167  94% 88% 73% 80%
C++ g++ #6 Make Error892
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
1.3Scala 21.5811.94376,052549
1.4OCaml 15.1215.16473,644563
1.4C gcc #2 3.433.4349,540594
1.5Haskell GHC #5 36.9713.76182,616611
2.1C gcc #7 13.714.19155,728850
2.3Go #6 69.5429.26455,104937
2.3PHP #4 1053.05539.691,809,628945
2.7C gcc #9 9.422.99229,0321103

 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