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  #4 4.974.98429,964919  1% 0% 1% 100%
1.8C gcc #3 9.099.10100,724906  1% 1% 1% 100%
2.2Ada 2005 GNAT #5 10.8810.91105,2002167  1% 0% 1% 100%
2.2Ada 2005 GNAT #4 10.8910.91105,2202167  0% 1% 1% 100%
2.3C++ g++ #6 11.4611.48150,264892  1% 2% 0% 100%
2.7Rust 13.5113.5373,104791  0% 1% 1% 100%
3.3Java  #3 16.3316.35526,588584  1% 1% 0% 100%
3.4Java  #2 16.8516.88527,148603  1% 1% 0% 100%
3.5Scala #4 17.3417.36520,128494  1% 1% 0% 100%
3.5Lisp SBCL #2 17.3417.37143,772649  1% 0% 0% 100%
3.8Haskell GHC #4 18.8818.91173,312612  0% 1% 1% 100%
3.8Haskell GHC 18.9819.01181,488521  0% 1% 1% 100%
3.9Fortran Intel #2 19.1719.1999,6241199  0% 1% 1% 100%
4.2C# Mono 20.7820.81116,084654  1% 0% 1% 100%
4.4Clojure 21.7521.78523,112657  0% 1% 1% 100%
4.5Clojure #2 22.5622.59586,368750  0% 1% 1% 100%
5.0Dart 24.8524.88196,824503  0% 1% 1% 100%
5.2F# Mono 25.9225.96151,024537  0% 1% 1% 100%
5.3Lisp SBCL 26.5026.53148,944612  1% 0% 0% 100%
5.5Racket #2 27.2127.25258,680640  1% 1% 1% 100%
6.3Clojure #6 31.1431.19539,368705  0% 1% 1% 100%
6.7Pascal Free Pascal 33.2633.2865,836769  0% 1% 0% 100%
6.7Erlang HiPE 33.2633.30532,108441  0% 1% 1% 100%
6.8OCaml #2 33.5933.65102,376784  1% 1% 0% 100%
6.9C gcc 34.4434.4666,776706  1% 0% 0% 100%
7.0OCaml #5 34.5834.62138,068496  0% 1% 1% 100%
7.4Racket 36.9336.98274,952495  1% 1% 0% 100%
7.6F# Mono #3 37.5437.59152,892565  1% 1% 1% 100%
8.4Erlang HiPE #2 42.0042.05283,248499  0% 1% 1% 100%
8.6Ada 2005 GNAT 42.8342.87101,160955  1% 0% 0% 100%
8.7JavaScript V8 43.4043.46472,452467  0% 1% 1% 100%
9.2C# Mono #2 45.7245.77264,084650  0% 1% 0% 100%
10Go #8 51.4951.54139,480814  0% 1% 1% 100%
13Smalltalk VisualWorks 66.1866.26317,936722  1% 1% 0% 100%
14F# Mono #2 68.2168.31221,496515  0% 1% 1% 100%
15C gcc #5 76.6876.72110,708963  1% 1% 0% 100%
16C# Mono #3 77.1677.21247,988723  0% 1% 1% 100%
16Go #4 82.0482.11176,812688  0% 1% 1% 100%
17Go #2 82.6182.68176,912694  1% 1% 1% 100%
17Go #9 83.9784.06150,624548  0% 1% 1% 100%
17Go 85.1185.18151,440516  0% 1% 1% 100%
17Go #7 86.1086.16151,476567  0% 1% 1% 100%
17Go #5 86.7386.81175,2321000  0% 1% 1% 100%
25Ada 2005 GNAT #3 123.11123.18331,3841342  0% 0% 0% 100%
34Ruby JRuby #4 166.86167.03903,012402  1% 1% 1% 100%
36Ruby #4 181.10181.20114,296402  1% 0% 1% 100%
37Ruby #5 186.18186.29114,6641123  1% 0% 0% 100%
38Fortran Intel 191.08191.31153,804826  0% 1% 1% 100%
39Ruby JRuby #3 195.50195.69891,804439  0% 1% 1% 100%
46Ruby 227.02227.12202,416412  1% 1% 0% 100%
46Ruby #3 230.78230.88159,932439  0% 0% 1% 100%
47Ruby #2 234.78234.89202,468413  1% 0% 1% 100%
48Ruby JRuby 240.99241.20907,856412  1% 1% 2% 100%
92Python 3 7 min7 min470,132596  1% 1% 0% 100%
97Lua #2 8 min8 min1,035,484446  0% 1% 1% 100%
109PHP #2 9 min9 min546,292472  1% 1% 0% 100%
119Perl 9 min9 min330,760448  1% 1% 0% 100%
120PHP 9 min9 min547,728504  1% 1% 0% 100%
139PHP #3 11 min11 min1,249,216483  1% 1% 0% 100%
166Ruby JRuby #5 13 min13 min849,3401123  2% 10% 5% 100%
C++ g++ #2 Make Error553
Perl #3 Failed706
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
 C++ g++ #7 Make Error  919
0.6C gcc #2 2.882.8925,860594
1.1C gcc #9 5.565.56114,6921103
1.9C gcc #7 9.409.41100,812850
2.5OCaml 12.3612.38236,304563
3.3Scala 16.5016.52408,588549
3.9Haskell GHC #5 19.2419.2588,312611
6.4Go #6 31.8131.84268,620861
6.4Go #3 31.9531.99340,004836
56PHP #4 280.01280.25955,376945
75Python 3 #7 374.64374.91466,520613
90Lua #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