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.409.409441544  0% 0% 100% 1%
1.0C++ g++ #7 9.679.671,0521545  1% 1% 100% 0%
1.0Fortran Intel #5 9.789.795161659  1% 0% 1% 100%
1.1C++ g++ #3 10.2610.271,4841763  0% 0% 100% 1%
1.1C gcc #4 10.5010.509681490  100% 0% 1% 1%
1.4C++ g++ #5 13.1113.121,5001749  0% 0% 100% 1%
1.9Ada 2005 GNAT #5 18.0018.001,9082436  0% 100% 1% 0%
2.1C++ g++ 19.3619.379801659  1% 100% 1% 0%
2.1C++ g++ #6 19.5319.541,0561668  0% 0% 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++ g++ #4 20.6320.647481428  0% 100% 0% 0%
2.2C gcc 20.7420.751,0081173  0% 1% 0% 100%
2.2C gcc #5 21.0821.097441429  0% 0% 100% 1%
2.3C gcc #6 21.2021.201,0081180  1% 100% 0% 1%
2.3C gcc #3 21.3021.319761208  0% 0% 100% 1%
2.3C# Mono #3 21.8021.8140,9321305  0% 100% 1% 0%
2.3Fortran Intel #4 21.9121.915121172  1% 0% 0% 100%
2.3C# Mono #8 22.0622.0640,9281343  1% 100% 0% 0%
2.4OCaml 22.2622.277081239  1% 0% 100% 1%
2.4C gcc #2 22.3522.359761263  0% 0% 100% 1%
2.4Java  #2 22.6822.6630,0361424  97% 3% 0% 1%
2.4C# Mono #2 22.7422.7440,6401410  1% 0% 100% 1%
2.4Go 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.5Scala 23.7223.6735,2361358  0% 100% 1% 0%
2.6C# Mono #6 24.5224.5340,6281289  100% 1% 0% 0%
2.6Rust 24.6324.636,0201474  0% 0% 100% 1%
2.7Ada 2005 GNAT #3 25.5725.582,0281740  0% 0% 100% 1%
2.8Ada 2005 GNAT 25.9425.952,0641608  7% 94% 0% 0%
2.8Clojure 27.6426.4266,8562324  3% 84% 17% 2%
2.8F# Mono 26.5126.5253,2921259  1% 0% 0% 100%
2.9Lisp SBCL #2 26.9726.986,6321398  2% 0% 1% 100%
2.9Clojure #2 28.2927.1271,4641440  2% 6% 3% 93%
2.9Dart #3 27.8227.6032,0921420  1% 89% 12% 1%
3.0C# Mono #7 28.1928.2042,7561539  1% 100% 1% 0%
3.0Haskell GHC 30.5128.286,8121706  3% 100% 3% 3%
3.2Dart #2 30.5830.3431,3721274  1% 3% 98% 1%
3.3C# Mono #4 30.8630.8740,6161461  100% 1% 2% 0%
3.4C# Mono #5 31.6831.6940,6001485  1% 0% 100% 1%
3.7Pascal Free Pascal 34.7534.7681308  0% 0% 100% 1%
3.8Pascal Free Pascal #3 35.3835.3981418  1% 1% 0% 100%
3.9Pascal Free Pascal #2 37.0137.0281322  1% 1% 0% 100%
4.0C# Mono 38.0438.0641,2521403  0% 0% 1% 100%
4.5Lisp SBCL 42.1642.176,6201363  100% 1% 0% 0%
5.7Racket #2 53.8253.8433,2201689  1% 0% 100% 1%
11Racket 105.75105.8245,6721496  1% 0% 100% 1%
21Erlang HiPE #3 193.28193.3319,3961399  1% 1% 1% 100%
40Ruby JRuby #2 6 min6 min755,9801137  23% 23% 28% 29%
45Erlang #3 7 min7 min33,2761399  7% 7% 37% 65%
60Hack #5 9 min9 min117,4841432  8% 45% 0% 48%
70Hack 10 min10 min126,2281288  18% 0% 0% 83%
72Ruby #2 11 min11 min7,3041137  54% 0% 46% 1%
74PHP #3 11 min11 min3,3681082  62% 0% 38% 1%
93Python 3 #2 14 min14 min7,8481228  0% 1% 100% 1%
96Python 3 15 min15 min5,6001181  1% 92% 8% 0%
115Perl #2 18 min18 min3,4521401  1% 0% 100% 1%
134Hack #3 20 min20 min117,3281080  0% 100% 1% 1%
Java  Failed1424
"wrong" (different) algorithm / less comparable programs
1.5C++ g++ #2 14.0014.011,4962288

 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