/mobile Handheld Friendly website

 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.0C gcc #7 14.384.32103,396850  81% 90% 99% 72%
1.3Ada 2005 GNAT #5 18.045.61106,1042167  82% 80% 78% 95%
1.3Ada 2005 GNAT #4 17.945.62117,8562167  77% 95% 73% 78%
1.4ATS #3 18.336.05218,6002143  73% 99% 64% 69%
1.5C++ g++ #6 19.066.60173,960892  60% 92% 75% 65%
1.8Fortran Intel #2 23.997.93116,9801199  68% 68% 98% 69%
2.1Java 7  21.359.21525,4201007  50% 70% 48% 65%
2.9Haskell GHC #4 36.9912.30365,756612  68% 67% 67% 99%
3.0Java 7  #2 16.9012.75485,056603  12% 62% 48% 12%
3.3Scala #4 18.9314.12462,460494  13% 28% 82% 13%
3.8OCaml #2 41.3316.37101,016784  95% 69% 55% 35%
3.9Erlang HiPE #2 52.6316.82646,636499  89% 75% 70% 81%
4.2ATS 17.9117.92132,104926  1% 0% 0% 100%
4.4Clojure 32.5219.05553,112657  53% 71% 27% 20%
4.6Haskell GHC 39.4719.95174,636521  33% 33% 33% 100%
4.7Lisp SBCL #2 20.4120.45220,104649  83% 0% 18% 0%
5.3C# Mono 22.6822.68137,004654  100% 0% 0% 0%
5.7C gcc #5 84.3824.68101,636963  90% 83% 85% 85%
6.2Racket #2 26.9226.94226,016640  0% 0% 0% 100%
6.6Clojure #6 41.8428.47554,804705  97% 19% 13% 19%
6.7Lisp SBCL 28.8028.85227,004612  0% 100% 0% 0%
7.5Ada 2005 GNAT #3 118.0432.50329,0121342  91% 90% 90% 93%
7.6C gcc 32.8432.8666,096706  96% 0% 0% 4%
7.7Pascal Free Pascal 33.2433.2665,844769  96% 0% 0% 4%
8.2OCaml #5 35.5235.56115,684496  0% 0% 100% 0%
8.7Racket 37.6737.71284,428495  0% 0% 100% 0%
8.8C++ g++ #2 38.1638.1999,080553  92% 0% 0% 8%
8.9F# Mono #3 38.2238.23179,420565  0% 0% 17% 83%
9.1Ada 2005 GNAT 39.3439.3799,440955  0% 0% 100% 0%
9.8Dart 42.3142.36153,364543  0% 0% 100% 0%
10C# Mono #2 42.8742.90304,604650  0% 0% 100% 0%
12Erlang HiPE 50.9250.98427,992441  2% 1% 97% 2%
12Go #2 203.2153.87305,172694  96% 94% 94% 96%
14Go #5 213.6961.72378,5201000  91% 88% 86% 83%
15F# Mono #2 66.6266.64276,364515  0% 0% 97% 3%
25Go 106.70106.71260,256516  0% 0% 100% 0%
29Ruby JRuby #3 204.38126.34879,972439  22% 22% 96% 21%
32Python 3 #6 8 min139.16685,880626  98% 93% 93% 93%
33Ruby JRuby 263.75141.78868,844412  31% 94% 31% 31%
41Fortran Intel 177.99178.17153,820826  0% 0% 0% 100%
54Ruby 2.0 #3 231.93232.04393,696439  86% 0% 0% 15%
62Perl #3 14 min265.80960,488706  71% 70% 97% 98%
149PHP 10 min10 min549,880504  5% 4% 1% 93%
157Perl 11 min11 min289,780448  98% 1% 0% 1%
208PHP #3 14 min14 min1,249,352483  8% 5% 0% 88%
Racket #3 Bad Output877
Ruby 2.0 Failed412
Ruby 2.0 #2 Failed413
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.4C gcc #9 6.531.82114,1241103
0.7C gcc #2 2.993.0025,148594
1.6Go #3 14.526.85107,700872
2.4Haskell GHC #5 27.0610.38151,668611
2.7Scala 15.2411.66392,740549
2.9OCaml 12.6512.67235,696563

 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