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.4Rust 21.3321.344,7841371  1% 100% 0% 0%
2.4Fortran Intel #3 21.5321.545121299  0% 0% 0% 100%
2.4C# Mono #3 21.7721.7722,1761305  1% 0% 100% 0%
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.5C# Mono #2 22.6822.6924,2121410  1% 1% 100% 0%
2.5Java  #2 22.9022.8719,5721424  99% 1% 1% 1%
2.5Go 22.9522.951,0361310  0% 0% 100% 1%
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.4424.4522,1721289  1% 1% 100% 0%
2.8F# Mono 25.1225.1431,7081259  100% 1% 1% 0%
2.9Ada 2005 GNAT 25.9525.961,5001608  1% 0% 0% 100%
2.9Scala 26.5226.4525,9041358  0% 1% 100% 0%
2.9Clojure 27.8726.6162,6242162  99% 2% 3% 2%
2.9Lisp SBCL #2 26.6926.708,6561398  1% 0% 100% 0%
3.0Clojure #2 28.1126.9565,9961440  2% 96% 5% 2%
3.1Dart #3 28.2228.0369,3321420  1% 86% 1% 15%
3.1Haskell GHC 30.2028.162,7201706  4% 4% 100% 4%
3.1C# Mono #7 28.1528.1622,7001539  1% 100% 0% 0%
3.4Dart #2 30.8430.5475,4841274  1% 1% 91% 10%
3.4C# Mono #4 30.8230.8322,4401461  1% 0% 1% 100%
3.5C# Mono #5 31.6131.6222,7481485  1% 100% 1% 0%
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.9938.0124,4801403  1% 99% 1% 1%
4.7Lisp SBCL 42.8442.868,6521363  1% 99% 0% 1%
5.9Racket #2 53.7753.7925,7321689  0% 0% 100% 0%
11Racket 103.63103.6828,5281496  0% 0% 1% 100%
14Erlang HiPE #3 125.85125.8813,1441399  79% 21% 0% 0%
41Erlang #3 6 min6 min12,0281399  43% 8% 0% 49%
45Ruby JRuby #2 6 min6 min665,3601137  30% 29% 25% 20%
67Hack #5 10 min10 min56,0841432  0% 0% 100% 1%
73Ruby #2 11 min11 min7,5041137  0% 1% 0% 100%
79PHP #3 11 min11 min3,3361082  100% 0% 0% 0%
90Hack 13 min13 min56,1161288  0% 100% 0% 0%
104Python 3 15 min15 min5,5641181  1% 0% 0% 100%
121Perl #2 18 min18 min2,6481401  0% 0% 0% 100%
144Hack #3 21 min21 min55,3441080  0% 1% 100% 0%
"wrong" (different) algorithm / less comparable programs
1.5C++ g++ #2 13.3613.371,0642288

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

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