/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 225.45225.54485,228412  0% 1% 100% 0%
1.0Ruby JRuby 261.64133.49891,920412  37% 89% 35% 36%
1.0Ruby #2 226.38226.47370,008413  0% 1% 1% 100%
1.1Ruby #3 220.52220.62343,968439  0% 1% 1% 100%
1.1Ruby JRuby #3 178.97111.92900,496439  31% 66% 41% 23%
1.1Erlang HiPE 50.9250.98427,992441  2% 1% 97% 2%
1.1Perl 11 min11 min289,788448  89% 10% 3% 7%
1.1PHP #2 9 min9 min546,272472  72% 24% 5% 4%
1.2PHP #3 15 min15 min1,256,324483  0% 0% 0% 100%
1.2Scala #4 18.5813.84480,552494  71% 13% 13% 39%
1.2Racket 37.3637.41280,268495  0% 1% 100% 0%
1.2OCaml #5 35.6835.73115,716496  0% 0% 0% 100%
1.2Erlang HiPE #2 52.6316.82646,636499  89% 75% 70% 81%
1.2Dart 35.0734.83154,400503  0% 1% 1% 100%
1.2PHP 10 min10 min547,708504  0% 97% 3% 0%
1.3F# Mono #2 67.4467.63275,504515  1% 89% 11% 1%
1.3Go 93.4993.47257,616516  1% 65% 1% 36%
1.3Haskell GHC 40.0320.51169,524521  32% 100% 33% 32%
1.3F# Mono 25.9325.93188,132537  3% 28% 51% 20%
1.3C++ g++ #2 37.7537.7899,092553  0% 0% 1% 100%
1.4F# Mono #3 37.3837.39163,240565  53% 1% 2% 46%
1.4Java  #3 17.7512.78471,136584  77% 15% 15% 34%
1.5Java  #2 18.0213.13471,008603  62% 21% 22% 34%
1.5Haskell GHC #4 40.3313.56398,172612  66% 67% 100% 66%
1.5Lisp SBCL 28.4928.53177,800612  0% 100% 1% 2%
1.5Python 3 #6 8 min139.26688,512626  93% 96% 96% 94%
1.6Racket #2 27.2327.26246,356640  1% 0% 0% 100%
1.6Lisp SBCL #2 19.1219.15177,796649  1% 100% 0% 0%
1.6C# Mono #2 42.9943.01319,372650  1% 100% 0% 1%
1.6C# Mono 21.8521.85119,736654  66% 1% 1% 34%
1.6Clojure 22.9916.53517,204657  29% 41% 34% 38%
1.7Go #4 153.9642.45307,056688  91% 90% 93% 90%
1.7Go #2 156.4742.94309,300694  93% 91% 90% 91%
1.7Clojure #6 32.9326.12523,000705  24% 58% 18% 27%
1.7C gcc 33.3233.3466,104706  0% 0% 100% 0%
1.7Perl #3 14 min258.43912,720706  94% 69% 100% 72%
1.8Clojure #2 32.4310.17517,208750  77% 78% 93% 75%
1.9Pascal Free Pascal 33.2433.2665,844769  96% 0% 0% 4%
1.9Rust 15.654.3790,028779  92% 84% 90% 94%
1.9OCaml #2 40.1416.27101,028784  36% 95% 49% 69%
2.0Fortran Intel 177.99178.17153,820826  0% 0% 0% 100%
2.2C++ g++ #7 12.244.0988,368919  70% 69% 95% 62%
2.3Ada 2005 GNAT 39.5039.5399,444955  0% 0% 0% 100%
2.3C gcc #5 80.6822.55109,188963  94% 85% 90% 91%
2.4Go #5 155.7940.43263,8521000  97% 97% 96% 96%
2.9Fortran Intel #2 23.997.93116,9801199  68% 68% 98% 69%
3.3Ada 2005 GNAT #3 117.3831.82329,1721342  92% 92% 92% 94%
5.3Ada 2005 GNAT #5 14.845.03117,8202167  86% 58% 76% 74%
5.3Ada 2005 GNAT #4 15.025.05117,9562167  68% 64% 92% 74%
C++ g++ #6 Make Error892
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
1.3Scala 17.5712.27359,384549
1.4OCaml 12.6312.65235,720563
1.4C gcc #2 3.003.0125,156594
1.5Haskell GHC #5 29.1411.85106,400611
2.1C gcc #7 11.203.50103,620850
2.3Go #6 50.0422.43237,836937
2.3PHP #4 673.93344.32957,240945
2.7C gcc #9 6.561.79114,1321103

 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