binary-trees benchmark N=20

Each chart bar shows how many times more Code, one ↓ binary-trees program used, compared to the program that used least Code.

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.0Ruby JRuby #4 166.86167.03903,012402  1% 1% 1% 100%
1.0Ruby #4 181.10181.20114,296402  1% 0% 1% 100%
1.0Ruby 227.02227.12202,416412  1% 1% 0% 100%
1.0Ruby JRuby 240.99241.20907,856412  1% 1% 2% 100%
1.0Ruby #2 234.78234.89202,468413  1% 0% 1% 100%
1.1Ruby JRuby #3 195.50195.69891,804439  0% 1% 1% 100%
1.1Ruby #3 230.78230.88159,932439  0% 0% 1% 100%
1.1Erlang HiPE 33.2633.30532,108441  0% 1% 1% 100%
1.1Lua #2 8 min8 min1,035,484446  0% 1% 1% 100%
1.1Perl 9 min9 min330,760448  1% 1% 0% 100%
1.2JavaScript V8 43.4043.46472,452467  0% 1% 1% 100%
1.2PHP #2 9 min9 min546,292472  1% 1% 0% 100%
1.2PHP #3 11 min11 min1,249,216483  1% 1% 0% 100%
1.2Scala #4 17.3417.36520,128494  1% 1% 0% 100%
1.2Racket 36.9336.98274,952495  1% 1% 0% 100%
1.2OCaml #5 34.5834.62138,068496  0% 1% 1% 100%
1.2Erlang HiPE #2 42.0042.05283,248499  0% 1% 1% 100%
1.3Dart 24.8524.88196,824503  0% 1% 1% 100%
1.3PHP 9 min9 min547,728504  1% 1% 0% 100%
1.3F# Mono #2 68.2168.31221,496515  0% 1% 1% 100%
1.3Go 85.1185.18151,440516  0% 1% 1% 100%
1.3Haskell GHC 18.9819.01181,488521  0% 1% 1% 100%
1.3F# Mono 25.9225.96151,024537  0% 1% 1% 100%
1.4Go #9 83.9784.06150,624548  0% 1% 1% 100%
1.4F# Mono #3 37.5437.59152,892565  1% 1% 1% 100%
1.4Go #7 86.1086.16151,476567  0% 1% 1% 100%
1.5Java  #3 16.3316.35526,588584  1% 1% 0% 100%
1.5Python 3 7 min7 min470,132596  1% 1% 0% 100%
1.5Java  #2 16.8516.88527,148603  1% 1% 0% 100%
1.5Lisp SBCL 26.5026.53148,944612  1% 0% 0% 100%
1.5Haskell GHC #4 18.8818.91173,312612  0% 1% 1% 100%
1.6Racket #2 27.2127.25258,680640  1% 1% 1% 100%
1.6Lisp SBCL #2 17.3417.37143,772649  1% 0% 0% 100%
1.6C# Mono #2 45.7245.77264,084650  0% 1% 0% 100%
1.6C# Mono 20.7820.81116,084654  1% 0% 1% 100%
1.6Clojure 21.7521.78523,112657  0% 1% 1% 100%
1.7Go #4 82.0482.11176,812688  0% 1% 1% 100%
1.7Go #2 82.6182.68176,912694  1% 1% 1% 100%
1.8Clojure #6 31.1431.19539,368705  0% 1% 1% 100%
1.8C gcc 34.4434.4666,776706  1% 0% 0% 100%
1.8Smalltalk VisualWorks 66.1866.26317,936722  1% 1% 0% 100%
1.8C# Mono #3 77.1677.21247,988723  0% 1% 1% 100%
1.9Clojure #2 22.5622.59586,368750  0% 1% 1% 100%
1.9Pascal Free Pascal 33.2633.2865,836769  0% 1% 0% 100%
2.0OCaml #2 33.5933.65102,376784  1% 1% 0% 100%
2.0Rust 13.5113.5373,104791  0% 1% 1% 100%
2.0Go #8 51.4951.54139,480814  0% 1% 1% 100%
2.1Fortran Intel 191.08191.31153,804826  0% 1% 1% 100%
2.2C++ g++ #6 11.4611.48150,264892  1% 2% 0% 100%
2.3C gcc #3 9.099.10100,724906  1% 1% 1% 100%
2.3Java  #4 4.974.98429,964919  1% 0% 1% 100%
2.4Ada 2005 GNAT 42.8342.87101,160955  1% 0% 0% 100%
2.4C gcc #5 76.6876.72110,708963  1% 1% 0% 100%
2.5Go #5 86.7386.81175,2321000  0% 1% 1% 100%
2.8Ruby JRuby #5 13 min13 min849,3401123  2% 10% 5% 100%
2.8Ruby #5 186.18186.29114,6641123  1% 0% 0% 100%
3.0Fortran Intel #2 19.1719.1999,6241199  0% 1% 1% 100%
3.3Ada 2005 GNAT #3 123.11123.18331,3841342  0% 0% 0% 100%
5.4Ada 2005 GNAT #4 10.8910.91105,2202167  0% 1% 1% 100%
5.4Ada 2005 GNAT #5 10.8810.91105,2002167  1% 0% 1% 100%
C++ g++ #2 Make Error553
Perl #3 Failed706
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
1.2Lua #3 449.64450.242,440,076477
1.4Scala 16.5016.52408,588549
1.4OCaml 12.3612.38236,304563
1.5C gcc #2 2.882.8925,860594
1.5Haskell GHC #5 19.2419.2588,312611
1.5Python 3 #7 374.64374.91466,520613
2.1Go #3 31.9531.99340,004836
2.1C gcc #7 9.409.41100,812850
2.1Go #6 31.8131.84268,620861
 C++ g++ #7 Make Error  919
2.4PHP #4 280.01280.25955,376945
2.7C gcc #9 5.565.56114,6921103
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