n-body benchmark N=50,000,000

Each chart bar shows how many times slower, one ↓ n-body 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++ g++ #8 9.359.354321544  98% 1% 3% 1%
1.0Fortran Intel #5 9.789.795161659  1% 0% 1% 100%
1.0C++ g++ #7 9.799.794321545  1% 0% 1% 100%
1.1C++ g++ #3 9.929.928241763  1% 1% 0% 100%
1.1C gcc #4 10.1910.194361490  0% 1% 1% 100%
1.4C++ g++ #5 13.4513.451,0641749  0% 1% 100% 0%
1.7Ada 2005 GNAT #5 15.4315.441,4882427  1% 1% 100% 0%
2.1C++ g++ #6 19.3419.354361668  1% 1% 100% 1%
2.1C++ g++ 19.5219.534361659  1% 1% 100% 1%
2.1Fortran Intel #2 19.8319.845081496  1% 0% 1% 100%
2.1Fortran Intel 19.9519.965121389  0% 1% 0% 100%
2.2C gcc #6 20.6020.604361180  0% 1% 100% 0%
2.2C gcc #3 20.6620.674361208  0% 0% 1% 100%
2.2C gcc 20.8120.824361173  1% 0% 0% 100%
2.2C gcc #5 20.9320.943601429  0% 1% 100% 0%
2.2C++ g++ #4 20.9320.943601428  1% 0% 100% 1%
2.3C# Mono #3 21.7621.7622,3081305  0% 0% 1% 100%
2.3Fortran Intel #4 21.9121.915121172  1% 0% 0% 100%
2.4C# Mono #8 22.0222.0322,2441343  1% 0% 1% 100%
2.4C gcc #2 22.2022.214321263  1% 1% 0% 100%
2.4OCaml 22.2622.277081239  1% 0% 100% 1%
2.4Java  #2 22.6422.6225,2321424  1% 2% 1% 97%
2.4Java  22.6622.6321,4481424  100% 0% 1% 1%
2.4C# Mono #2 22.6822.6822,1361410  1% 100% 0% 0%
2.5Go 22.9322.921,0201310  1% 0% 100% 0%
2.5Haskell GHC #2 24.4023.176,8041874  3% 2% 3% 100%
2.5Fortran Intel #3 23.1823.195201299  1% 0% 1% 100%
2.5Ada 2005 GNAT #3 23.2723.281,5001740  1% 0% 0% 100%
2.6C# Mono #6 24.4724.4721,9921289  1% 100% 0% 0%
2.6Rust 24.6324.634,9721474  1% 0% 100% 1%
2.7F# Mono 25.0925.0933,0121259  1% 100% 1% 2%
2.8Ada 2005 GNAT 25.9525.961,5001608  1% 0% 0% 100%
2.8Scala 26.5026.4429,8201358  98% 2% 3% 1%
2.9Lisp SBCL #2 26.9726.986,6321398  2% 0% 1% 100%
2.9Clojure #2 28.2027.0173,6641440  98% 3% 2% 3%
2.9Clojure 28.4227.1582,0522162  55% 2% 2% 48%
3.0Dart #3 27.9127.7425,9841420  100% 1% 0% 1%
3.0C# Mono #7 28.1428.1522,5881539  0% 0% 0% 100%
3.0Haskell GHC 30.5128.286,8121706  3% 100% 3% 3%
3.2Dart #2 30.4030.1825,4921274  1% 1% 100% 1%
3.3C# Mono #4 30.8130.8222,3561461  68% 1% 1% 33%
3.4C# Mono #5 31.5931.6022,7721485  0% 1% 1% 100%
3.7Pascal Free Pascal 34.7534.7681308  0% 0% 100% 1%
3.8Pascal Free Pascal #3 35.3835.3981418  1% 1% 0% 100%
4.0Pascal Free Pascal #2 37.0137.0281322  1% 1% 0% 100%
4.1C# Mono 37.9737.9922,4041403  0% 1% 0% 100%
4.5Lisp SBCL 42.1642.176,6201363  100% 1% 0% 0%
5.8Racket #2 53.8253.8433,2201689  1% 0% 100% 1%
11Racket 105.75105.8245,6721496  1% 0% 100% 1%
20Erlang HiPE #3 185.00185.0317,8281399  1% 0% 99% 1%
40Ruby JRuby #2 6 min6 min755,9801137  23% 23% 28% 29%
43Erlang #3 6 min6 min25,6761399  1% 1% 100% 0%
61Hack #5 9 min9 min76,7561432  1% 100% 0% 0%
66Hack 10 min10 min78,9361288  83% 18% 1% 1%
72Ruby #2 11 min11 min7,3041137  54% 0% 46% 1%
75PHP #3 11 min11 min3,3681082  62% 0% 38% 1%
86Hack #3 13 min13 min80,9721080  100% 0% 0% 1%
97Python 3 15 min15 min5,6001181  1% 92% 8% 0%
115Perl #2 18 min18 min3,4521401  1% 0% 100% 1%
"wrong" (different) algorithm / less comparable programs
1.4C++ g++ #2 13.3613.371,0642288

 n-body benchmark : Double-precision N-body simulation

You can write your own program for this task and contribute to the benchmarks game by following these general instructions.

More specifically:

ndiff -abserr 1.0e-8 program output N = 1000 with this 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 model the orbits of Jovian planets, using the same simple symplectic-integrator - see the Java program.

For background information see N-body problem. Useful symplectic integrators are freely available, for example the HNBody Symplectic Integration Package.

Thanks to Mark C. Lewis for this benchmark.

Revised BSD license

  Home   Conclusions   License   Play