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.

    sort sortsort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0Java  #4 5.605.61434,772919  1% 1% 0% 100%
1.7C gcc #3 9.269.28150,364906  0% 0% 1% 100%
1.9Ada 2005 GNAT #5 10.6710.70160,6682167  1% 1% 0% 100%
1.9Ada 2005 GNAT #4 10.6810.71160,6762167  1% 1% 0% 100%
2.3C++ g++ #6 12.8812.90297,932892  1% 0% 0% 100%
2.5Rust 14.0314.05119,464791  1% 1% 1% 100%
3.0Fortran Intel #2 16.9116.92149,3801199  1% 1% 1% 100%
3.1Java  #2 17.1617.18519,692603  1% 1% 1% 100%
3.1Java  #3 17.2617.28518,964584  1% 1% 0% 100%
3.1Scala #4 17.4717.50518,364494  1% 0% 0% 100%
3.9Haskell GHC #4 21.9722.01311,828612  0% 1% 1% 100%
4.3C# Mono 23.9624.01165,896654  2% 1% 0% 100%
4.4Haskell GHC 24.5724.62314,852521  0% 1% 1% 100%
4.4Clojure #6 24.6224.66558,580705  1% 1% 1% 100%
4.4Lisp SBCL #2 24.8724.92292,580649  0% 1% 1% 100%
4.5F# Mono 25.2025.24160,280537  1% 1% 1% 100%
4.5Clojure #2 25.5025.53616,588750  1% 1% 0% 100%
4.8Clojure 26.8626.90597,940657  0% 1% 0% 100%
5.6Dart 31.6631.69332,500503  0% 1% 0% 100%
5.8Lisp SBCL 32.3532.40311,068612  0% 1% 1% 100%
6.5C gcc 36.6236.65132,456706  1% 0% 1% 100%
6.6Erlang HiPE 37.2537.311,057,544441  0% 1% 1% 100%
6.7Hack #3 37.6237.65596,756480  0% 1% 0% 100%
6.8C++ g++ #2 37.9437.98199,212553  1% 1% 0% 100%
7.0Ada 2005 GNAT 39.1639.20200,008955  2% 1% 1% 100%
7.2Racket #2 40.5140.57413,456640  1% 0% 1% 100%
7.4Pascal Free Pascal 41.6141.65131,376769  1% 1% 1% 100%
7.7OCaml #2 43.3243.39202,856784  2% 0% 0% 100%
8.0OCaml #5 44.8944.95274,680496  0% 1% 0% 100%
8.7Racket 48.4748.56464,724495  1% 1% 1% 100%
8.7Erlang HiPE #2 48.9649.03512,732499  0% 0% 1% 100%
9.0F# Mono #3 50.6250.71256,252565  2% 2% 1% 100%
9.1Fortran Intel 50.8050.84132,032826  1% 1% 0% 100%
9.6JavaScript V8 53.5753.65912,160467  1% 1% 0% 100%
9.9Go #8 55.2855.35264,284814  0% 1% 1% 100%
10C# Mono #2 56.9857.07455,844650  1% 1% 0% 100%
13C# Mono #3 75.4675.55395,688723  1% 1% 1% 100%
14C gcc #5 79.6579.71221,888963  1% 1% 1% 100%
14Smalltalk VisualWorks 81.0481.16329,960722  0% 0% 0% 100%
16Go #4 88.9489.04338,388688  1% 1% 1% 100%
16Go #2 89.0189.12339,308694  0% 1% 0% 100%
16Go 90.9591.06288,536516  0% 1% 1% 100%
16Go #9 92.1392.24290,548548  0% 0% 1% 100%
17Go #7 92.6892.79290,256567  1% 1% 1% 100%
17Go #5 94.2994.41335,3841000  1% 1% 1% 100%
17Ada 2005 GNAT #3 97.4297.49660,7761342  1% 1% 0% 100%
19Hack #2 107.90107.98725,936468  0% 1% 1% 100%
20Hack 113.16113.24727,696506  0% 1% 1% 100%
29Ruby #4 165.21165.40240,392402  0% 1% 1% 100%
32Ruby #5 176.92177.11240,6801123  1% 1% 1% 100%
36Ruby #3 201.01201.20298,000439  1% 1% 0% 100%
36Ruby JRuby #3 201.82202.061,017,040439  1% 1% 1% 100%
36Ruby 204.15204.37388,384412  0% 1% 1% 100%
37Ruby #2 207.57207.76387,892413  0% 1% 1% 100%
68Ruby JRuby 6 min6 min1,017,692412  0% 1% 1% 100%
74Lua #2 6 min6 min1,672,244446  0% 1% 1% 100%
79Python 3 7 min7 min836,008596  1% 1% 0% 100%
88Ruby JRuby #4 8 min8 min912,756402  0% 1% 1% 100%
109PHP #2 10 min10 min1,021,788472  1% 1% 0% 100%
109Perl 10 min10 min546,676448  0% 1% 1% 100%
119PHP 11 min11 min1,021,916504  1% 1% 0% 100%
227Ruby JRuby #5 21 min21 min938,2361123  0% 1% 1% 100%
F# Mono #2 Failed515
Perl #3 Failed706
PHP #3 Failed483
Racket #3 Bad Output877
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.6C gcc #2 3.583.5950,424594
1.3C gcc #9 7.187.19229,3681103
1.6C gcc #7 9.159.16150,500850
1.8C++ g++ #7 10.1710.19102,052919
2.7OCaml 15.3615.38476,712563
2.9Scala 16.1516.17420,848549
4.0Haskell GHC #5 22.2222.24204,300611
6.4Go #3 36.0536.11650,604836
6.7Go #6 37.4937.55509,756861
63Python 3 #7 353.59353.98836,232613
64PHP #4 356.91357.301,826,308945
192Lua #3 419.861.003,663,800477

 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