/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 10 min229.741,167,076412  74% 81% 58% 53%
1.1Ruby JRuby #3 10 min228.431,166,852439  82% 53% 58% 72%
1.1Ruby 2.0 #3 203.16203.36436,644439  0% 78% 22% 0%
1.1Erlang 119.16119.30866,752441  4% 93% 3% 0%
1.1Erlang HiPE 68.1668.25958,748441  0% 98% 0% 2%
1.1Perl 10 min10 min480,528448  44% 56% 0% 0%
1.2PHP #3 19 min19 min2,385,540483  15% 17% 6% 62%
1.2Scala #4 16.3712.46477,616494  12% 12% 11% 99%
1.2Racket 49.8449.91452,728495  0% 100% 0% 0%
1.2OCaml #5 41.3441.40223,180496  0% 0% 0% 100%
1.2Erlang HiPE #2 69.7228.011,028,396499  52% 57% 47% 95%
1.2Erlang #2 122.3734.07828,976499  93% 87% 92% 88%
1.2PHP 11 min11 min1,021,804504  8% 6% 1% 87%
1.3F# Mono #2 148.4290.02274,616515  22% 43% 62% 39%
1.3Go 122.58122.66475,328516  0% 0% 50% 50%
1.3Haskell GHC 54.4524.21359,360521  42% 100% 42% 41%
1.3Dart 114.06114.22237,968543  0% 0% 0% 100%
1.3C++ g++ #2 37.7037.73197,756553  95% 0% 0% 5%
1.4F# Mono #3 78.0048.09245,164565  75% 21% 27% 40%
1.5Java 7  #2 16.9412.32476,228603  13% 27% 86% 13%
1.5Haskell GHC #4 65.0020.04787,716612  90% 85% 75% 75%
1.5Lisp SBCL 27.4027.45448,668612  0% 30% 70% 0%
1.5Python 3 #6 8 min142.511,209,460626  93% 95% 98% 93%
1.6Racket #2 40.8840.94400,344640  13% 87% 0% 0%
1.6Lisp SBCL #2 20.5020.54439,708649  1% 0% 100% 0%
1.6C# Mono #2 93.3855.97472,228650  23% 23% 56% 66%
1.6C# Mono 79.2340.87143,172654  32% 48% 47% 69%
1.6Clojure 30.1118.50596,772657  24% 95% 22% 22%
1.7Go #4 238.3363.78580,720688  93% 95% 94% 93%
1.7Go #2 240.0164.30538,624694  93% 93% 95% 94%
1.7Clojure #6 25.9518.33531,756705  71% 15% 15% 43%
1.7Perl #3 12 min211.701,593,648706  78% 95% 96% 89%
1.7C gcc 35.6135.64131,668706  0% 0% 0% 100%
1.9Pascal Free Pascal 40.7940.82131,380769  0% 0% 100% 0%
1.9OCaml #2 67.3327.17201,692784  40% 84% 55% 71%
2.0Fortran Intel 45.5445.57132,316826  98% 0% 2% 2%
2.1C gcc #7 15.714.79155,788850  93% 67% 78% 94%
2.2C++ g++ #6 32.349.25360,404892  89% 79% 95% 88%
2.2ATS 16.6116.64198,252926  0% 0% 0% 100%
2.3Ada 2005 GNAT 37.8637.90198,176955  0% 0% 100% 0%
2.3C gcc #5 78.7420.70219,168963  92% 97% 93% 99%
2.4Go #5 233.8863.20486,5601000  95% 94% 93% 91%
2.4Java 7  22.319.24523,7841007  37% 65% 58% 83%
2.9Fortran Intel #2 23.397.55181,0001199  69% 72% 99% 72%
3.3Ada 2005 GNAT #3 102.8429.26656,6401342  91% 88% 87% 89%
5.2ATS #3 18.296.19328,5162143  64% 99% 71% 62%
5.3Ada 2005 GNAT #4 20.116.20176,8602167  82% 79% 76% 92%
5.3Ada 2005 GNAT #5 19.926.27176,8242167  71% 82% 93% 75%
Racket #3 Bad Output877
Ruby 2.0 #2 Failed413
Ruby 2.0 Failed412
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
1.3Scala 15.5210.39334,868549
1.4OCaml 14.7214.76485,364563
1.4C gcc #2 3.343.3549,544594
1.5Haskell GHC #5 40.9715.67247,864611
2.1Go #3 17.218.19214,644872
2.7C gcc #9 9.893.01229,0441103

 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