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.0Fortran Intel #5 9.079.075121659  0% 1% 100% 1%
1.0C++ g++ #8 9.359.354321544  98% 1% 3% 1%
1.1C++ 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.5C++ 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.2C++ g++ 19.5219.534361659  1% 1% 100% 1%
2.2Fortran Intel #2 19.9419.955121496  0% 0% 100% 0%
2.2Fortran Intel 20.0720.085121389  0% 0% 0% 100%
2.3C gcc #6 20.6020.604361180  0% 1% 100% 0%
2.3C gcc #3 20.6620.674361208  0% 0% 1% 100%
2.3C gcc 20.8120.824361173  1% 0% 0% 100%
2.3C gcc #5 20.9320.943601429  0% 1% 100% 0%
2.3C++ g++ #4 20.9320.943601428  1% 0% 100% 1%
2.3Rust 20.9920.994,8241371  1% 0% 0% 100%
2.4Fortran Intel #3 21.5321.545121299  0% 0% 0% 100%
2.4C# Mono #3 21.7621.7622,3081305  0% 0% 1% 100%
2.4OCaml 21.8621.877161239  100% 0% 0% 0%
2.4C gcc #2 22.2022.214321263  1% 1% 0% 100%
2.5Fortran Intel #4 22.4722.485121172  0% 0% 0% 100%
2.5Java  #2 22.6422.6225,2321424  1% 2% 1% 97%
2.5C# Mono #2 22.6822.6822,1361410  1% 100% 0% 0%
2.5Rust #3 22.8622.864,8121367  0% 1% 100% 0%
2.5Go 22.9322.921,0201310  1% 0% 100% 0%
2.6Haskell GHC #2 24.3523.172,7281874  2% 3% 100% 2%
2.6Ada 2005 GNAT #3 23.2723.281,5001740  1% 0% 0% 100%
2.7C# Mono #6 24.4724.4721,9921289  1% 100% 0% 0%
2.8F# Mono 25.0925.0933,0121259  1% 100% 1% 2%
2.9Ada 2005 GNAT 25.9525.961,5001608  1% 0% 0% 100%
2.9Rust #2 26.1926.204,8241321  1% 0% 100% 0%
2.9Scala 26.5026.4429,8201358  98% 2% 3% 1%
3.0Lisp SBCL #2 26.9826.9910,6641398  1% 0% 100% 1%
3.0Clojure #2 28.2027.0173,6641440  98% 3% 2% 3%
3.0Clojure 28.4227.1582,0522162  55% 2% 2% 48%
3.1Dart #3 28.0327.9217,2401420  1% 1% 100% 1%
3.1C# Mono #7 28.1428.1522,5881539  0% 0% 0% 100%
3.1Haskell GHC 30.2028.162,7201706  4% 4% 100% 4%
3.3Dart #2 29.8529.6717,4521274  100% 1% 1% 1%
3.4C# Mono #4 30.8130.8222,3561461  68% 1% 1% 33%
3.5C# Mono #5 31.5931.6022,7721485  0% 1% 1% 100%
3.8Pascal Free Pascal 34.7534.7681308  0% 0% 100% 1%
3.9Pascal Free Pascal #3 35.3835.3981418  1% 1% 0% 100%
4.1Pascal Free Pascal #2 37.0137.0281322  1% 1% 0% 100%
4.2C# Mono 37.9737.9922,4041403  0% 1% 0% 100%
4.6Lisp SBCL 42.1542.1610,6641363  1% 0% 0% 100%
5.9Racket #2 53.7753.7925,7321689  0% 0% 100% 0%
11Racket 103.63103.6828,5281496  0% 0% 1% 100%
20Erlang HiPE #3 185.00185.0317,8281399  1% 0% 99% 1%
41Ruby JRuby #2 6 min6 min755,9801137  23% 23% 28% 29%
44Erlang #3 6 min6 min25,6761399  1% 1% 100% 0%
67Hack #5 10 min10 min87,2001432  16% 1% 84% 0%
71Ruby #2 10 min10 min7,1601137  1% 0% 0% 100%
79PHP #3 11 min11 min3,3361082  100% 0% 0% 0%
87Hack 13 min13 min87,2041288  98% 3% 1% 1%
104Python 3 15 min15 min5,5641181  1% 0% 0% 100%
112Hack #3 16 min16 min83,2001080  72% 16% 14% 0%
121Perl #2 18 min18 min2,6481401  0% 0% 0% 100%
"wrong" (different) algorithm / less comparable programs
1.5C++ 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