/mobile Handheld Friendly website

 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.

     sortsortsort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0C++ g++ #7 12.244.0988,368919  70% 69% 95% 62%
1.2Ada 2005 GNAT #5 14.845.03117,8202167  86% 58% 76% 74%
1.2Ada 2005 GNAT #4 15.025.05117,9562167  68% 64% 92% 74%
1.3Rust 15.654.3790,028779  92% 84% 90% 94%
1.5Java  #3 17.7512.78471,136584  77% 15% 15% 34%
1.5Java  #2 18.0213.13471,008603  62% 21% 22% 34%
1.5Scala #4 18.5813.84480,552494  71% 13% 13% 39%
1.6Lisp SBCL #2 19.1219.15177,796649  1% 100% 0% 0%
1.8C# Mono 21.8521.85119,736654  66% 1% 1% 34%
2.0Fortran Intel #2 23.997.93116,9801199  68% 68% 98% 69%
2.1F# Mono 25.9325.93188,132537  3% 28% 51% 20%
2.2Racket #2 27.2327.26246,356640  1% 0% 0% 100%
2.3Lisp SBCL 28.4928.53177,800612  0% 100% 1% 2%
2.6Clojure 31.2418.96542,672657  71% 34% 31% 30%
2.7Pascal Free Pascal 33.2433.2665,844769  96% 0% 0% 4%
2.7C gcc 33.3233.3466,104706  0% 0% 100% 0%
2.9Dart 35.0734.83154,400503  0% 1% 1% 100%
2.9OCaml #5 35.6835.73115,716496  0% 0% 0% 100%
3.1Racket 37.3637.41280,268495  0% 1% 100% 0%
3.1F# Mono #3 37.3837.39163,240565  53% 1% 2% 46%
3.1C++ g++ #2 37.7537.7899,092553  0% 0% 1% 100%
3.2Ada 2005 GNAT 39.5039.5399,444955  0% 0% 0% 100%
3.3Haskell GHC 40.0320.51169,524521  32% 100% 33% 32%
3.3OCaml #2 40.1416.27101,028784  36% 95% 49% 69%
3.3Haskell GHC #4 40.3313.56398,172612  66% 67% 100% 66%
3.3Clojure #6 40.3628.03546,948705  31% 52% 41% 22%
3.5Clojure #2 42.9313.11568,716750  81% 81% 84% 84%
3.5C# Mono #2 42.9943.01319,372650  1% 100% 0% 1%
4.2Erlang HiPE 50.9250.98427,992441  2% 1% 97% 2%
4.3Erlang HiPE #2 52.6316.82646,636499  89% 75% 70% 81%
5.5F# Mono #2 67.4467.63275,504515  1% 89% 11% 1%
6.6C gcc #5 80.6822.55109,188963  94% 85% 90% 91%
7.6Go 93.4993.47257,616516  1% 65% 1% 36%
9.6Ada 2005 GNAT #3 117.3831.82329,1721342  92% 92% 92% 94%
13Go #4 153.9642.45307,056688  91% 90% 93% 90%
13Go #5 155.7940.43263,8521000  97% 97% 96% 96%
13Go #2 156.4742.94309,300694  93% 91% 90% 91%
15Fortran Intel 177.99178.17153,820826  0% 0% 0% 100%
15Ruby JRuby #3 178.97111.92900,496439  31% 66% 41% 23%
18Ruby #3 220.52220.62343,968439  0% 1% 1% 100%
18Ruby 225.45225.54485,228412  0% 1% 100% 0%
18Ruby #2 226.38226.47370,008413  0% 1% 1% 100%
21Ruby JRuby 261.64133.49891,920412  37% 89% 35% 36%
43Python 3 #6 8 min139.26688,512626  93% 96% 96% 94%
45PHP #2 9 min9 min546,272472  72% 24% 5% 4%
51PHP 10 min10 min547,708504  0% 97% 3% 0%
54Perl 11 min11 min289,788448  89% 10% 3% 7%
71Perl #3 14 min258.43912,720706  94% 69% 100% 72%
75PHP #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.2C gcc #2 3.003.0125,156594
0.5C gcc #9 6.561.79114,1321103
0.9C gcc #7 11.203.50103,620850
1.0OCaml 12.6312.65235,720563
1.4Scala 17.5712.27359,384549
2.4Haskell GHC #5 29.1411.85106,400611
4.1Go #6 50.0422.43237,836937
55PHP #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