/mobile Handheld Friendly website

 binary-trees benchmark N=20

Each chart bar shows how many times more Memory, one ↓ binary-trees program used, compared to the program that used least Memory.

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.

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

 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