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.0Java  #6 7.487.50401,292583  0% 1% 1% 100%
1.2C gcc #3 9.099.10100,724906  1% 1% 1% 100%
1.4Java  #5 10.6810.70518,220926  1% 1% 0% 100%
1.5Ada 2005 GNAT #5 10.8810.91105,2002167  1% 0% 1% 100%
1.5Ada 2005 GNAT #4 10.8910.91105,2202167  0% 1% 1% 100%
1.5C++ g++ #6 11.4611.48150,264892  1% 2% 0% 100%
1.8Rust 13.4513.4673,100791  0% 1% 1% 100%
1.9Go #6 14.4314.45103,012752  0% 1% 1% 100%
2.2Java  #3 16.3316.35526,588584  1% 1% 0% 100%
2.3Java  #2 16.8516.88527,148603  1% 1% 0% 100%
2.3Lisp SBCL #2 17.3417.37143,772649  1% 0% 0% 100%
2.3Scala #4 17.3417.36520,128494  1% 1% 0% 100%
2.5Haskell GHC #4 18.8818.91173,312612  0% 1% 1% 100%
2.5Haskell GHC 18.9819.01181,488521  0% 1% 1% 100%
2.6Fortran Intel #2 19.1719.1999,6241199  0% 1% 1% 100%
2.8C# Mono 20.7820.81116,084654  1% 0% 1% 100%
2.9Clojure 21.3421.37530,752657  1% 0% 1% 100%
3.0Clojure #2 22.3722.41526,916750  5% 4% 3% 100%
3.2Dart 24.2024.23205,872503  0% 1% 1% 100%
3.5F# Mono 25.9225.96151,024537  0% 1% 1% 100%
3.5Lisp SBCL 26.5026.53148,944612  1% 0% 0% 100%
3.6Racket #2 27.2127.25258,680640  1% 1% 1% 100%
3.8Clojure #6 28.1428.17555,808705  1% 1% 1% 100%
4.4Pascal Free Pascal 33.2633.2865,836769  0% 1% 0% 100%
4.5OCaml #2 33.5933.65102,376784  1% 1% 0% 100%
4.6C gcc 34.4434.4666,776706  1% 0% 0% 100%
4.6OCaml #5 34.5834.62138,068496  0% 1% 1% 100%
4.9Racket 36.9336.98274,952495  1% 1% 0% 100%
5.0Erlang HiPE 37.3037.36532,976441  1% 2% 1% 100%
5.0F# Mono #3 37.5437.59152,892565  1% 1% 1% 100%
5.5JavaScript V8 41.4941.55467,564467  0% 0% 1% 100%
5.7Ada 2005 GNAT 42.8342.87101,160955  1% 0% 0% 100%
6.1Erlang HiPE #2 45.3045.36234,644499  0% 1% 1% 100%
6.1C# Mono #2 45.7245.77264,084650  0% 1% 0% 100%
6.9Go #8 51.4951.54139,480814  0% 1% 1% 100%
8.8Smalltalk VisualWorks 66.1866.26317,936722  1% 1% 0% 100%
9.1F# Mono #2 68.2168.31221,496515  0% 1% 1% 100%
10C gcc #5 76.6876.72110,708963  1% 1% 0% 100%
10C# Mono #3 77.1677.21247,988723  0% 1% 1% 100%
11Go #4 82.0482.11176,812688  0% 1% 1% 100%
11Go #2 82.6182.68176,912694  1% 1% 1% 100%
11Go #9 83.9784.06150,624548  0% 1% 1% 100%
11Go 85.1185.18151,440516  0% 1% 1% 100%
12Go #7 86.1086.16151,476567  0% 1% 1% 100%
12Go #5 86.7386.81175,2321000  0% 1% 1% 100%
16Ada 2005 GNAT #3 123.11123.18331,3841342  0% 0% 0% 100%
22Ruby JRuby #4 166.86167.03903,012402  1% 1% 1% 100%
24Ruby #4 181.10181.20114,296402  1% 0% 1% 100%
25Ruby #5 186.18186.29114,6641123  1% 0% 0% 100%
26Fortran Intel 191.08191.31153,804826  0% 1% 1% 100%
26Ruby JRuby #3 195.50195.69891,804439  0% 1% 1% 100%
30Ruby 227.02227.12202,416412  1% 1% 0% 100%
31Ruby #3 230.78230.88159,932439  0% 0% 1% 100%
31Ruby #2 234.78234.89202,468413  1% 0% 1% 100%
32Ruby JRuby 240.99241.20907,856412  1% 1% 2% 100%
61Python 3 7 min7 min470,132596  1% 1% 0% 100%
64Lua #2 8 min8 min1,035,484446  0% 1% 1% 100%
72PHP #2 9 min9 min546,292472  1% 1% 0% 100%
79Perl 9 min9 min330,760448  1% 1% 0% 100%
80PHP 9 min9 min547,728504  1% 1% 0% 100%
92PHP #3 11 min11 min1,249,216483  1% 1% 0% 100%
111Ruby JRuby #5 13 min13 min849,3401123  2% 10% 5% 100%
147Scala #5 18 min18 min456,196688  2% 9% 8% 100%
C++ g++ #2 Make Error553
Go #3 Bad Output830
Perl #3 Failed706
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
 C++ g++ #7 Make Error  919
0.4C gcc #2 2.882.8925,860594
0.7C gcc #9 5.565.56114,6921103
1.3C gcc #7 9.409.41100,812850
1.7OCaml 12.3612.38236,304563
2.2Scala 16.5016.52408,588549
2.6Haskell GHC #5 19.2419.2588,312611
37PHP #4 280.01280.25955,376945
50Python 3 #7 374.64374.91466,520613
60Lua #3 449.64450.242,440,076477
missing benchmark programs
C CINT No program

 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