/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.

    sort sortsort
  ×   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.1Rust 15.654.3790,028779  92% 84% 90% 94%
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.9Fortran Intel #2 23.997.93116,9801199  68% 68% 98% 69%
2.5Clojure #2 32.4310.17517,208750  77% 78% 93% 75%
3.1Java  #3 17.7512.78471,136584  77% 15% 15% 34%
3.2Java  #2 18.0213.13471,008603  62% 21% 22% 34%
3.3Haskell GHC #4 40.3313.56398,172612  66% 67% 100% 66%
3.4Scala #4 18.5813.84480,552494  71% 13% 13% 39%
4.0OCaml #2 40.1416.27101,028784  36% 95% 49% 69%
4.0Clojure 22.9916.53517,204657  29% 41% 34% 38%
4.1Erlang HiPE #2 52.6316.82646,636499  89% 75% 70% 81%
4.7Lisp SBCL #2 19.1219.15177,796649  1% 100% 0% 0%
5.0Haskell GHC 40.0320.51169,524521  32% 100% 33% 32%
5.3C# Mono 21.8521.85119,736654  66% 1% 1% 34%
5.5C gcc #5 80.6822.55109,188963  94% 85% 90% 91%
6.3F# Mono 25.9325.93188,132537  3% 28% 51% 20%
6.4Clojure #6 32.9326.12523,000705  24% 58% 18% 27%
6.7Racket #2 27.2327.26246,356640  1% 0% 0% 100%
7.0Lisp SBCL 28.4928.53177,800612  0% 100% 1% 2%
7.8Ada 2005 GNAT #3 117.3831.82329,1721342  92% 92% 92% 94%
8.1Pascal Free Pascal 33.2433.2665,844769  96% 0% 0% 4%
8.2C gcc 33.3233.3466,104706  0% 0% 100% 0%
8.5Dart 35.0734.83154,400503  0% 1% 1% 100%
8.7OCaml #5 35.6835.73115,716496  0% 0% 0% 100%
9.1F# Mono #3 37.3837.39163,240565  53% 1% 2% 46%
9.1Racket 37.3637.41280,268495  0% 1% 100% 0%
9.2C++ g++ #2 37.7537.7899,092553  0% 0% 1% 100%
9.7Ada 2005 GNAT 39.5039.5399,444955  0% 0% 0% 100%
9.9Go #5 155.7940.43263,8521000  97% 97% 96% 96%
10Go #4 153.9642.45307,056688  91% 90% 93% 90%
10Go #2 156.4742.94309,300694  93% 91% 90% 91%
11C# Mono #2 42.9943.01319,372650  1% 100% 0% 1%
12Erlang HiPE 50.9250.98427,992441  2% 1% 97% 2%
17F# Mono #2 67.4467.63275,504515  1% 89% 11% 1%
23Go 93.4993.47257,616516  1% 65% 1% 36%
27Ruby JRuby #3 178.97111.92900,496439  31% 66% 41% 23%
33Ruby JRuby 261.64133.49891,920412  37% 89% 35% 36%
34Python 3 #6 8 min139.26688,512626  93% 96% 96% 94%
44Fortran Intel 177.99178.17153,820826  0% 0% 0% 100%
54Ruby #3 220.52220.62343,968439  0% 1% 1% 100%
55Ruby 225.45225.54485,228412  0% 1% 100% 0%
55Ruby #2 226.38226.47370,008413  0% 1% 1% 100%
63Perl #3 14 min258.43912,720706  94% 69% 100% 72%
134PHP #2 9 min9 min546,272472  72% 24% 5% 4%
153PHP 10 min10 min547,708504  0% 97% 3% 0%
163Perl 11 min11 min289,788448  89% 10% 3% 7%
225PHP #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 #9 6.561.79114,1321103
0.7C gcc #2 3.003.0125,156594
0.9C gcc #7 11.203.50103,620850
2.9Haskell GHC #5 29.1411.85106,400611
3.0Scala 17.5712.27359,384549
3.1OCaml 12.6312.65235,720563
5.5Go #6 50.0422.43237,836937
84PHP #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