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 212.24212.32135,148402  0% 1% 1% 100%
1.0Ruby 257.16257.25174,872412  1% 1% 1% 100%
1.0Ruby JRuby 240.99241.20907,856412  1% 1% 2% 100%
1.0Ruby #2 260.61260.70210,040413  0% 1% 1% 100%
1.1Ruby JRuby #3 195.50195.69891,804439  0% 1% 1% 100%
1.1Ruby #3 271.48271.59185,784439  3% 3% 2% 100%
1.1Erlang HiPE 50.4950.55443,172441  0% 0% 0% 100%
1.1Lua #2 7 min7 min1,033,624446  0% 14% 4% 100%
1.1Perl 10 min10 min289,324448  0% 0% 0% 100%
1.2JavaScript V8 40.3040.35485,356467  0% 0% 1% 100%
1.2PHP #2 9 min9 min546,272472  0% 0% 0% 100%
1.2PHP #3 15 min15 min1,260,280483  1% 1% 4% 100%
1.2Scala #4 17.5917.61516,760494  1% 0% 1% 100%
1.2Racket 37.3837.43281,180495  0% 1% 1% 100%
1.2OCaml #5 35.8935.93115,712496  0% 0% 0% 100%
1.2Erlang HiPE #2 47.5747.63338,644499  0% 0% 0% 100%
1.3Dart 21.0321.07181,972503  1% 1% 1% 100%
1.3PHP 10 min10 min546,248504  0% 0% 0% 100%
1.3F# Mono #2 61.8861.94259,592515  0% 1% 1% 100%
1.3Go 89.8289.91170,752516  1% 1% 0% 100%
1.3Haskell GHC 18.9118.94166,212521  0% 0% 0% 100%
1.3F# Mono 23.5923.62182,728537  0% 1% 1% 100%
1.4Go #9 90.3190.39173,604548  0% 3% 1% 100%
1.4C++ g++ #2 38.8538.8799,080553  0% 0% 1% 100%
1.4F# Mono #3 36.8236.86170,584565  0% 1% 1% 100%
1.4Go #7 88.6488.71170,400567  1% 1% 0% 100%
1.5Java  #3 16.4116.44521,176584  0% 1% 1% 100%
1.5Java  #2 16.6416.66522,964603  0% 1% 0% 100%
1.5Lisp SBCL 27.2427.27193,672612  1% 0% 0% 100%
1.5Haskell GHC #4 18.2318.25173,344612  0% 1% 1% 100%
1.6Python 3 #6 8 min8 min688,448626  1% 1% 1% 100%
1.6Racket #2 27.1427.18218,080640  1% 1% 1% 100%
1.6Lisp SBCL #2 18.7018.73193,676649  1% 0% 0% 100%
1.6C# Mono #2 43.0643.11320,640650  0% 1% 0% 100%
1.6C# Mono 20.1020.13114,172654  0% 1% 1% 100%
1.6Clojure 21.7521.78523,112657  0% 1% 1% 100%
1.7Go #4 90.4890.57199,244688  1% 0% 0% 100%
1.7Go #2 90.5790.65199,132694  1% 1% 1% 100%
1.8Clojure #6 31.1431.19539,368705  0% 1% 1% 100%
1.8C gcc 34.1634.1866,096706  0% 0% 1% 100%
1.8Smalltalk VisualWorks 65.6065.67316,312722  0% 0% 0% 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 35.0035.07101,028784  0% 0% 0% 100%
2.0Rust 14.1714.19130,104788  1% 1% 0% 100%
2.0Go #8 54.0054.05134,696814  0% 1% 0% 100%
2.1Fortran Intel 173.18173.35153,800826  0% 0% 0% 100%
2.2C++ g++ #6 10.9210.94148,508892  1% 1% 0% 100%
2.3C gcc #3 9.399.4099,424906  0% 72% 34% 100%
2.4Ada 2005 GNAT 40.6540.6899,416955  1% 0% 0% 100%
2.4C gcc #5 76.1676.20109,632963  1% 1% 0% 100%
2.5Go #5 91.1391.23196,0401000  1% 1% 0% 100%
2.8Ruby JRuby #5 13 min13 min849,3401123  2% 10% 5% 100%
2.8Ruby #5 214.33214.43130,8921123  0% 1% 1% 100%
3.0Fortran Intel #2 23.7723.7999,6161199  0% 0% 0% 100%
3.3Ada 2005 GNAT #3 114.60114.66329,0601342  0% 1% 1% 100%
5.4Ada 2005 GNAT #4 11.1511.17105,6762167  0% 1% 1% 100%
5.4Ada 2005 GNAT #5 11.1711.20105,6842167  0% 1% 1% 100%
Perl #3 Failed706
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
1.2Lua #3 477.10477.692,963,916477
1.4Scala 16.3116.33391,860549
1.4OCaml 12.7412.77235,724563
1.5C gcc #2 2.952.9625,064594
1.5Haskell GHC #5 20.1920.2188,332611
 Go #3 Failed  836
2.1C gcc #7 9.459.4699,448850
2.3C++ g++ #7 10.4210.4366,996919
2.3Go #6 33.4433.48273,412937
2.4PHP #4 541.62542.15957,228945
2.7C gcc #9 6.226.23114,3361103
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