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.354361544  1% 1% 1% 100%
1.0Fortran Intel #5 9.789.795161659  1% 0% 1% 100%
1.0C++ 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.4C++ 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.1C++ g++ 19.5419.544361659  1% 0% 1% 100%
2.1Fortran Intel #2 19.8319.845081496  1% 1% 0% 100%
2.1Fortran Intel 19.9519.955121389  1% 0% 0% 100%
2.2C gcc #6 20.5920.604321180  1% 0% 1% 100%
2.2C gcc #3 20.6620.674361208  1% 0% 0% 100%
2.2C gcc 20.8120.824361173  0% 1% 1% 100%
2.2C++ g++ #4 20.9320.943601428  1% 1% 0% 100%
2.2C gcc #5 20.9320.943601429  1% 0% 0% 100%
2.3C# Mono #3 21.7521.7622,3041305  1% 1% 0% 100%
2.3Fortran Intel #4 21.9021.915121172  1% 0% 0% 100%
2.4C# Mono #8 22.0222.0222,2441343  0% 0% 1% 100%
2.4C gcc #2 22.2022.214361263  0% 1% 1% 100%
2.4OCaml 22.2622.277081239  1% 0% 0% 100%
2.4Haskell GHC #2 22.6522.662,3401874  1% 0% 1% 100%
2.4Java  #2 22.6722.6723,8121424  1% 0% 1% 100%
2.4Java  22.6722.6819,6761424  0% 1% 1% 100%
2.4C# Mono #2 22.6722.6822,1041410  1% 1% 1% 100%
2.5Go 22.9222.931,0201310  0% 0% 1% 100%
2.5Fortran Intel #3 23.0923.105201299  1% 0% 0% 100%
2.5Ada 2005 GNAT #3 23.2723.281,5001740  1% 0% 0% 100%
2.6C# Mono #6 24.4624.4721,9921289  0% 0% 0% 100%
2.6Rust 24.6324.634,9721474  1% 0% 0% 100%
2.7F# Mono 25.0925.1033,0161259  0% 0% 1% 100%
2.8Ada 2005 GNAT 25.9225.931,5001608  1% 0% 0% 100%
2.8Scala 26.4826.4828,6841358  1% 0% 1% 100%
2.9Lisp SBCL #2 26.9826.986,6321398  1% 1% 0% 100%
2.9Haskell GHC 27.4027.412,3361706  1% 0% 1% 100%
2.9Dart #3 27.5427.5526,7121420  1% 0% 0% 100%
3.0Clojure 27.7127.7262,1602162  0% 1% 0% 100%
3.0Clojure #2 27.9627.9761,6681440  0% 1% 1% 100%
3.0C# Mono #7 28.1428.1522,5721539  1% 0% 1% 100%
3.2Dart #2 30.3630.3726,3201274  1% 0% 0% 100%
3.3C# Mono #4 30.8130.8222,3521461  1% 0% 1% 100%
3.4C# Mono #5 31.5931.6022,7641485  1% 0% 0% 100%
3.6JavaScript V8 33.5733.5812,1321287  1% 1% 0% 100%
3.7Pascal Free Pascal 34.7534.7681308  1% 0% 1% 100%
3.8Pascal Free Pascal #3 35.4035.4181418  1% 1% 0% 100%
3.9JavaScript V8 #2 36.4736.487,6641527  0% 0% 0% 100%
4.0Pascal Free Pascal #2 37.0137.0281322  1% 0% 0% 100%
4.1C# Mono 37.9737.9822,4041403  1% 0% 0% 100%
4.5Lisp SBCL 42.1642.176,6201363  1% 0% 0% 100%
5.8Racket #2 53.8253.8633,2561689  0% 1% 1% 100%
11Racket 105.09105.1941,9641496  0% 1% 1% 100%
19Erlang HiPE #3 182.00182.0613,2521399  1% 0% 0% 100%
21Smalltalk VisualWorks 193.92193.9851,6241652  1% 1% 1% 100%
40Ruby JRuby #2 6 min6 min752,5001137  1% 1% 1% 100%
47Lua #4 7 min7 min1,0801305  1% 0% 0% 100%
47Lua #2 7 min7 min1,0721193  3% 4% 5% 100%
58Lua 8 min8 min1,0681201  1% 0% 0% 100%
58Hack #5 9 min9 min76,8881432  0% 1% 0% 100%
68Hack 10 min10 min78,7961288  0% 0% 0% 100%
70PHP #3 10 min10 min3,3641082  1% 0% 0% 100%
74Ruby #2 11 min11 min7,0721137  1% 0% 0% 100%
87Hack #3 13 min13 min82,9761080  0% 0% 0% 100%
95Python 3 14 min14 min5,5961181  0% 0% 0% 100%
116Perl #2 18 min18 min3,1561401  1% 1% 0% 100%
"wrong" (different) algorithm / less comparable programs
1.4C++ g++ #2 13.3913.401,0682288
3.6JavaScript V8 #3 33.2033.217,8521505

 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