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 gcc #3 9.682.97105,024906  93% 77% 87% 72%
1.2Rust 13.593.5981,236791  96% 93% 93% 99%
1.7Ada 2005 GNAT #4 15.114.98107,3402167  72% 93% 67% 75%
1.7Ada 2005 GNAT #5 15.144.99113,6122167  70% 69% 93% 76%
1.7C++ g++ #6 16.575.08180,752892  81% 85% 82% 83%
2.0Java  #5 19.645.88513,180926  95% 79% 87% 76%
2.0Java  #6 8.265.93386,484583  47% 15% 37% 43%
2.2Fortran Intel #2 19.946.57125,0161199  67% 70% 71% 96%
3.0Go #6 18.258.95100,584752  53% 50% 50% 50%
3.5Clojure #2 33.9210.45534,788750  84% 90% 78% 73%
4.4Java  #3 17.9113.03488,716584  29% 64% 16% 30%
4.5Erlang HiPE #2 48.5113.33534,160499  93% 90% 95% 88%
4.6Java  #2 19.0313.56505,456603  50% 52% 17% 23%
4.6Haskell GHC #4 40.4113.66405,572612  67% 99% 67% 66%
4.7Scala #4 19.1613.92513,600494  20% 50% 45% 28%
4.9OCaml #2 38.4114.41102,344784  77% 33% 100% 60%
5.7Clojure 24.3316.86532,412657  27% 44% 46% 29%
5.8Go #8 52.2817.08129,276814  77% 76% 76% 78%
5.9Lisp SBCL #2 17.3417.37148,988649  0% 32% 1% 69%
6.8C# Mono 21.3320.29116,456654  20% 6% 39% 41%
7.0Haskell GHC 40.9320.77179,716521  33% 33% 100% 33%
7.7Clojure #6 31.6422.93545,252705  44% 46% 18% 31%
8.2Dart 25.8524.34204,088503  27% 69% 9% 2%
8.4F# Mono 26.3125.02126,628537  6% 80% 20% 1%
8.9Lisp SBCL 26.5126.54148,944612  0% 0% 0% 100%
9.3Racket #2 27.7027.73245,224640  8% 1% 1% 93%
11C# Mono #3 63.5132.85394,684723  49% 48% 49% 46%
11Pascal Free Pascal 33.1933.2165,836769  1% 1% 1% 100%
12Racket 34.2634.29278,232495  0% 0% 100% 1%
12C gcc 34.4034.4266,784706  100% 0% 0% 0%
12OCaml #5 34.4234.46138,072496  0% 1% 1% 100%
12Ada 2005 GNAT #3 123.9036.41331,0801342  86% 84% 86% 85%
12Erlang HiPE 36.4136.44537,356441  1% 3% 0% 97%
12F# Mono #3 38.2336.68153,824565  100% 5% 1% 1%
14Ada 2005 GNAT 42.9743.00101,240955  1% 1% 100% 0%
15C# Mono #2 46.5344.81254,416650  0% 2% 4% 100%
16C gcc #5 128.0948.80113,984963  52% 61% 72% 80%
18Go #5 169.3452.51156,2841000  82% 81% 80% 81%
19Go #4 190.9655.53165,020688  87% 86% 86% 87%
19Go #2 190.8655.92165,224694  86% 86% 86% 86%
22F# Mono #2 69.4166.41213,544515  23% 1% 5% 78%
23Ruby #5 193.7567.48114,5881123  63% 63% 66% 96%
30Go #9 163.8289.54138,016548  48% 47% 43% 46%
31Go 168.5991.91139,492516  49% 48% 43% 44%
31Go #7 171.2392.70141,676567  49% 49% 46% 48%
36Ruby JRuby #5 6 min106.002,243,1081123  96% 97% 95% 96%
42Python 3 7 min125.06470,428596  93% 97% 94% 94%
48Scala #5 6 min141.83478,068688  77% 73% 72% 76%
59Ruby JRuby #4 215.63174.401,844,572402  22% 27% 26% 50%
60Ruby JRuby #3 214.10178.531,449,820439  22% 55% 26% 19%
66Ruby #4 194.22194.32114,320402  1% 99% 0% 2%
68Fortran Intel 202.15202.38154,072826  98% 4% 5% 2%
69Ruby JRuby 5 min204.692,176,152412  49% 34% 30% 53%
78Ruby #2 230.87230.98202,420413  0% 1% 1% 100%
78Ruby #3 230.91231.04159,432439  1% 1% 55% 46%
79Ruby 233.65233.76202,472412  1% 67% 0% 34%
91Perl #3 14 min268.791,018,156706  90% 95% 73% 76%
178PHP #2 8 min8 min549,952472  34% 66% 1% 1%
199PHP 9 min9 min546,228504  9% 78% 14% 1%
226PHP #3 11 min11 min1,255,012483  1% 23% 54% 24%
233Perl 11 min11 min330,928448  10% 34% 64% 13%
C++ g++ #2 Make Error553
Go #3 Bad Output830
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
 C++ g++ #7 Make Error  919
0.5C gcc #9 5.821.60114,6681103
1.0C gcc #2 2.842.8525,948594
1.3C gcc #7 11.823.84104,952850
3.9Haskell GHC #5 28.4911.49114,856611
3.9Scala 17.5211.67408,468549
4.2OCaml 12.3412.36236,300563
34Python 3 #7 383.25101.01466,084613
55PHP #4 313.26162.10955,116945

 binary-trees benchmark : Allocate and deallocate many many binary trees

You can write your own program for this task and contribute to the benchmarks game by following these general instructions.

More specifically:

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