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.059.055121659  1% 0% 1% 100%
1.0C++ g++ #8 9.359.354361544  1% 1% 1% 100%
1.1C++ g++ #7 9.799.794361545  0% 1% 1% 100%
1.1C++ g++ #3 9.929.928281763  0% 1% 0% 100%
1.1C gcc #4 10.1910.194321490  1% 0% 0% 100%
1.5C++ g++ #5 13.4513.451,0681749  1% 0% 1% 100%
1.7Ada 2005 GNAT #5 15.4315.441,4922427  1% 0% 0% 100%
2.1C++ g++ #6 19.3419.354321668  1% 1% 1% 100%
2.2C++ g++ 19.5419.544361659  1% 0% 1% 100%
2.2Fortran Intel #2 19.9519.965121496  0% 0% 0% 100%
2.2Fortran Intel 20.0620.065121389  0% 0% 0% 100%
2.3C gcc #6 20.5920.604321180  1% 0% 1% 100%
2.3C gcc #3 20.6620.674361208  1% 0% 0% 100%
2.3C gcc 20.8120.824361173  0% 1% 1% 100%
2.3C++ g++ #4 20.9320.943601428  1% 1% 0% 100%
2.3C gcc #5 20.9320.943601429  1% 0% 0% 100%
2.4Rust 21.3321.344,7841371  0% 1% 0% 100%
2.4Fortran Intel #3 21.5321.545121299  0% 0% 0% 100%
2.4C# Mono #3 21.7621.7722,2561305  1% 1% 0% 100%
2.4OCaml 21.8621.877201239  0% 1% 0% 100%
2.5C gcc #2 22.2022.214361263  0% 1% 1% 100%
2.5Fortran Intel #4 22.4722.485121172  0% 0% 0% 100%
2.5Haskell GHC #2 22.6522.662,3441874  0% 1% 1% 100%
2.5Java  #2 22.6622.6719,5681424  0% 0% 0% 100%
2.5C# Mono #2 22.6822.6922,1081410  0% 1% 0% 100%
2.5Go 22.9622.961,0361310  1% 0% 0% 100%
2.6Ada 2005 GNAT #3 23.2723.281,5001740  1% 0% 0% 100%
2.7C# Mono #6 24.4724.4821,9721289  1% 1% 0% 100%
2.8F# Mono 25.1025.1233,0281259  1% 1% 0% 100%
2.9Ada 2005 GNAT 25.9225.931,5001608  1% 0% 0% 100%
2.9Scala 26.4826.4926,0401358  0% 0% 0% 100%
2.9Lisp SBCL #2 26.6726.688,6561398  0% 1% 0% 100%
3.0Haskell GHC 27.4027.412,3601706  1% 0% 0% 100%
3.1Clojure 27.6627.6758,8642162  0% 1% 1% 100%
3.1Clojure #2 27.9027.9260,2841440  1% 0% 0% 100%
3.1C# Mono #7 28.1528.1622,5321539  1% 1% 0% 100%
3.1Dart #3 28.3528.3618,7761420  0% 1% 0% 100%
3.4Dart #2 30.7030.7117,9281274  1% 1% 0% 100%
3.4C# Mono #4 30.8230.8322,3401461  0% 1% 1% 100%
3.5C# Mono #5 31.6031.6122,7561485  1% 0% 0% 100%
3.8Pascal Free Pascal 34.7534.7681308  1% 0% 1% 100%
3.9Pascal Free Pascal #3 35.4035.4181418  1% 1% 0% 100%
4.0JavaScript V8 36.3636.3810,3761287  1% 0% 0% 100%
4.1Pascal Free Pascal #2 37.0137.0281322  1% 0% 0% 100%
4.2JavaScript V8 #2 37.5837.609,5841527  0% 1% 1% 100%
4.2C# Mono 37.9838.0022,3721403  1% 1% 0% 100%
4.7Lisp SBCL 42.8542.878,6561363  1% 0% 0% 100%
6.0Racket #2 53.9153.9427,5281689  0% 1% 1% 100%
11Racket 103.92104.0128,5361496  0% 1% 1% 100%
13Erlang HiPE #3 119.80119.8412,1081399  0% 0% 0% 100%
21Smalltalk VisualWorks 192.75192.8042,8801652  0% 0% 0% 100%
46Ruby JRuby #2 6 min6 min691,3921137  0% 1% 1% 100%
50Lua #4 7 min7 min1,0401305  0% 0% 0% 100%
52Lua #2 7 min7 min1,0401193  0% 0% 0% 100%
57Lua 8 min8 min1,0361201  0% 0% 0% 100%
67Hack #5 10 min10 min56,0801432  1% 0% 0% 100%
73Ruby #2 10 min10 min7,5201137  0% 0% 0% 100%
78PHP #3 11 min11 min3,3401082  0% 0% 0% 100%
90Hack 13 min13 min56,1161288  1% 0% 0% 100%
103Python 3 15 min15 min5,5721181  1% 0% 0% 100%
115Perl #2 17 min17 min2,6201401  0% 0% 0% 100%
143Hack #3 21 min21 min55,3441080  1% 0% 0% 100%
"wrong" (different) algorithm / less comparable programs
1.5C++ g++ #2 13.3913.401,0682288
3.7JavaScript V8 #3 33.5533.579,8681505

 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