/mobile Handheld Friendly website

 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 227.06227.16400,436412  0% 0% 1% 100%
1.0Ruby JRuby 253.43253.68895,044412  0% 1% 1% 100%
1.0Ruby #2 222.74222.85557,644413  0% 1% 1% 100%
1.1Ruby #3 226.44226.55409,360439  0% 1% 1% 100%
1.1Ruby JRuby #3 168.68168.87899,264439  1% 1% 1% 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.1JavaScript V8 39.8639.92267,848467  0% 1% 1% 100%
1.1PHP #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.4617.49506,212494  1% 1% 0% 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.2Dart 34.6934.73123,020503  1% 1% 0% 100%
1.2PHP 10 min10 min546,248504  0% 0% 0% 100%
1.3F# Mono #2 67.1467.22281,144515  0% 1% 1% 100%
1.3Go 93.5593.63255,844516  1% 1% 1% 100%
1.3Haskell GHC 18.9118.94166,212521  0% 0% 0% 100%
1.3F# Mono 25.8425.88189,180537  0% 0% 1% 100%
1.3C++ g++ #2 38.0438.0699,092553  0% 1% 1% 100%
1.4F# Mono #3 37.3637.40167,460565  0% 1% 1% 100%
1.4Java  #3 16.2816.30511,448584  1% 1% 0% 100%
1.5Java  #2 16.5616.59510,068603  1% 1% 1% 100%
1.5Lisp SBCL 28.5028.54177,784612  0% 0% 1% 100%
1.5Haskell GHC #4 18.2318.25173,344612  0% 1% 1% 100%
1.5Python 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 19.1219.15177,812649  0% 1% 0% 100%
1.6C# Mono #2 42.5542.60319,368650  0% 0% 1% 100%
1.6C# Mono 21.5921.62120,948654  0% 1% 1% 100%
1.6Clojure 30.2430.28547,012657  1% 1% 0% 100%
1.7Go #4 110.33110.42305,600688  0% 1% 0% 100%
1.7Go #2 112.38112.47305,416694  0% 1% 0% 100%
1.7Clojure #6 41.0641.11561,116705  1% 1% 0% 100%
1.7C gcc 33.4033.4266,104706  0% 0% 0% 100%
1.8Smalltalk VisualWorks 65.6065.67316,312722  0% 0% 0% 100%
1.8Clojure #2 31.0831.12547,480750  1% 1% 1% 100%
1.9Pascal Free Pascal 33.2533.2765,828769  0% 1% 1% 100%
1.9Rust 15.1315.1590,480779  0% 0% 1% 100%
1.9OCaml #2 35.0035.07101,028784  0% 0% 0% 100%
2.0Fortran Intel 173.18173.35153,800826  0% 0% 0% 100%
2.2C++ g++ #7 10.3610.3867,008919  0% 1% 0% 100%
2.3Ada 2005 GNAT 39.9840.0199,444955  1% 1% 0% 100%
2.3C gcc #5 75.8275.87109,668963  0% 1% 1% 100%
2.4Go #5 113.29113.39315,4121000  0% 1% 0% 100%
2.9Fortran Intel #2 23.7723.7999,6161199  0% 0% 0% 100%
3.3Ada 2005 GNAT #3 115.88115.94328,9841342  0% 1% 1% 100%
5.3Ada 2005 GNAT #5 11.2211.25105,6962167  0% 1% 1% 100%
5.3Ada 2005 GNAT #4 11.1811.20105,6962167  1% 1% 1% 100%
C++ g++ #6 Make Error892
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.3Scala 16.1416.16379,632549
1.4OCaml 12.7412.77235,724563
1.4C gcc #2 2.993.0025,152594
1.5Haskell GHC #5 20.1920.2188,332611
2.1C gcc #7 9.479.4899,412850
2.3Go #6 36.2836.31232,636937
2.3PHP #4 541.62542.15957,228945
2.7C gcc #9 6.236.24114,1281103
missing benchmark programs
C CINT No program

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

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