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 #3 10.183.26160,856906  64% 76% 75% 99%
1.2Rust 14.703.97120,968791  96% 92% 92% 94%
1.7Ada 2005 GNAT #4 18.005.46178,5082167  93% 76% 77% 88%
1.7Ada 2005 GNAT #5 17.805.49179,0802167  72% 91% 87% 78%
1.7Java  #6 8.005.67356,656583  39% 39% 36% 32%
1.8Fortran Intel #2 19.176.02184,4201199  77% 73% 70% 100%
2.0Java  #5 21.116.48522,972926  81% 86% 89% 73%
2.5C++ g++ #6 27.948.28359,596892  90% 76% 91% 83%
3.5Go #6 24.3111.33185,988752  55% 53% 54% 54%
4.1Java  #3 19.2913.34517,584584  42% 32% 27% 46%
4.1Java  #2 18.8913.40518,596603  22% 57% 41% 23%
4.2Scala #4 19.5313.65518,700494  16% 57% 38% 34%
4.3Clojure #2 45.9513.92628,936750  91% 86% 81% 75%
5.7Clojure 28.6618.54622,804657  46% 42% 43% 28%
6.0Erlang HiPE #2 71.4219.54908,280499  96% 89% 92% 91%
6.2Go #8 64.1420.13257,128814  80% 81% 80% 80%
6.3Clojure #6 33.2820.56617,604705  55% 35% 34% 39%
6.4Haskell GHC #4 66.7220.72830,536612  75% 80% 94% 75%
6.4C gcc #5 79.5420.88221,316963  99% 90% 96% 97%
7.5C# Mono 25.9224.34162,152654  8% 100% 0% 1%
7.5OCaml #2 70.9124.46202,980784  72% 75% 58% 86%
7.7Lisp SBCL #2 24.9124.95294,672649  0% 100% 1% 0%
7.7F# Mono 26.7725.23165,268537  95% 4% 7% 1%
8.2Haskell GHC 57.4026.83359,548521  73% 65% 38% 39%
9.2Erlang #2 107.3629.89850,240499  88% 96% 91% 86%
9.2Ada 2005 GNAT #3 100.9629.96658,8281342  84% 85% 84% 84%
9.2Dart 32.7929.99338,428503  49% 9% 6% 48%
10Lisp SBCL 32.4032.45311,072612  100% 0% 1% 1%
11Hack #3 34.7734.81383,096480  1% 15% 85% 1%
11C gcc 36.7636.79132,456706  100% 0% 0% 1%
12C++ g++ #2 37.9638.00199,300553  69% 32% 0% 1%
12Ada 2005 GNAT 39.1439.17200,056955  1% 100% 0% 0%
12Erlang HiPE 39.2239.261,036,380441  1% 4% 79% 18%
12Racket #2 40.4640.51412,592640  1% 0% 100% 1%
13Pascal Free Pascal 40.9140.96131,380769  0% 1% 0% 100%
14OCaml #5 44.5544.61274,692496  0% 1% 1% 100%
15Racket 48.6448.71333,344495  1% 0% 100% 0%
15F# Mono #3 53.2050.24229,448565  30% 26% 21% 30%
18C# Mono #2 60.5957.51456,756650  9% 6% 2% 90%
18Go #5 184.2459.78287,6921000  79% 76% 77% 78%
18Go #4 209.9160.20322,420688  88% 87% 88% 88%
19Ruby #5 176.2260.91240,6761123  95% 65% 63% 69%
19Go #2 214.5962.16330,164694  87% 87% 86% 87%
20Fortran Intel 66.6166.65132,308826  31% 57% 0% 13%
21F# Mono #2 72.4068.43281,960515  36% 22% 4% 48%
26Erlang 85.9085.98816,572441  61% 0% 40% 1%
28Go #9 172.0992.60280,696548  50% 49% 48% 41%
29Go 175.9194.75280,024516  46% 48% 46% 48%
30Go #7 184.4197.38279,044567  52% 47% 46% 48%
30Ruby JRuby #4 157.7997.791,168,552402  52% 25% 25% 68%
31Ruby JRuby #3 160.76101.781,191,532439  28% 47% 52% 33%
33Hack #2 107.72107.80445,032468  1% 2% 99% 0%
37Hack 121.25121.34449,040506  1% 26% 75% 1%
40Python 3 8 min129.60835,824596  93% 94% 98% 93%
42Scala #5 6 min137.70476,200688  77% 75% 74% 75%
52Ruby #4 168.26168.44240,348402  0% 1% 0% 100%
61Ruby #2 197.50197.72388,004413  45% 41% 5% 11%
62Ruby #3 200.33200.56291,636439  36% 1% 38% 27%
62Ruby 201.88202.06388,196412  1% 1% 100% 0%
69Ruby JRuby #5 14 min226.171,205,2961123  95% 96% 95% 95%
73Perl #3 13 min238.081,706,872706  94% 72% 96% 77%
186PHP #2 10 min10 min1,021,744472  38% 22% 42% 0%
196Perl 10 min10 min546,828448  6% 95% 0% 1%
205PHP 11 min11 min1,031,360504  10% 0% 91% 1%
228PHP #3 12 min12 min2,379,344483  14% 21% 0% 66%
C# Mono #3 Failed723
Go #3 Bad Output830
Racket #3 Bad Output877
Ruby JRuby Failed412
Scala #2 Failed641
"wrong" (different) algorithm / less comparable programs
0.9C gcc #9 9.562.92229,2961103
1.1C gcc #2 3.583.5950,460594
1.3C gcc #7 13.764.22156,760850
1.5C++ g++ #7 15.264.74134,308919
3.4Scala 17.5211.02412,472549
4.2Haskell GHC #5 37.0413.72190,724611
4.7OCaml 15.2815.30476,828563
29Python 3 #7 363.4595.99836,208613
67PHP #4 420.11218.831,834,480945

 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