n-body benchmark N=50,000,000

Each chart bar shows how many times more Memory, one ↓ n-body program used, compared to the program that used least Memory.

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.

    sortsort sort
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0Pascal Free Pascal #2 37.0137.0281322  1% 0% 0% 100%
1.0Pascal Free Pascal #3 35.4035.4181418  1% 1% 0% 100%
1.0Pascal Free Pascal 34.7534.7681308  1% 0% 1% 100%
64Fortran Intel #2 19.8319.845081496  1% 1% 0% 100%
64Fortran Intel #4 21.9021.915121172  1% 0% 0% 100%
64Fortran Intel 19.9519.955121389  1% 0% 0% 100%
65Fortran Intel #5 9.789.795161659  1% 0% 1% 100%
65Fortran Intel #3 23.0923.105201299  1% 0% 0% 100%
89OCaml 22.2622.277081239  1% 0% 0% 100%
91C++ g++ #4 20.6320.647281428  0% 0% 1% 100%
94C gcc #5 21.0821.097481429  0% 0% 0% 100%
112C gcc #2 22.3422.358961263  0% 0% 0% 100%
122C gcc #3 21.2821.299721208  0% 1% 0% 100%
126C gcc #6 21.2021.201,0081180  0% 1% 0% 100%
126C gcc #4 10.4910.501,0081490  0% 1% 1% 100%
127C gcc 20.7320.741,0121173  0% 0% 1% 100%
128Go 22.9222.931,0201310  0% 0% 1% 100%
128C++ g++ #6 19.5219.531,0201668  0% 0% 0% 100%
134Lua 8 min8 min1,0681201  1% 0% 0% 100%
134Lua #2 7 min7 min1,0721193  3% 4% 5% 100%
135Lua #4 7 min7 min1,0801305  1% 0% 0% 100%
136C++ g++ #8 9.399.401,0841544  0% 1% 1% 100%
136C++ g++ #7 9.679.671,0841545  0% 0% 1% 100%
136C++ g++ 19.3619.361,0881659  0% 1% 0% 100%
192C++ g++ #3 10.2710.281,5361763  0% 0% 0% 100%
192C++ g++ #5 13.1113.121,5361749  0% 1% 0% 100%
245Ada 2005 GNAT #5 18.0018.011,9562436  1% 0% 2% 100%
259Ada 2005 GNAT #3 25.3425.342,0681740  1% 1% 0% 100%
259Ada 2005 GNAT 25.9425.952,0721608  1% 1% 0% 100%
292Haskell GHC 27.4027.412,3361706  1% 0% 1% 100%
293Haskell GHC #2 22.6522.662,3401874  1% 0% 1% 100%
395Perl #2 18 min18 min3,1561401  1% 1% 0% 100%
421PHP #3 10 min10 min3,3641082  1% 0% 0% 100%
700Python 3 14 min14 min5,5961181  0% 0% 0% 100%
755Rust 24.6224.636,0361474  1% 0% 1% 100%
828Lisp SBCL 42.1642.176,6201363  1% 0% 0% 100%
829Lisp SBCL #2 26.9826.986,6321398  1% 1% 0% 100%
884Ruby #2 11 min11 min7,0721137  1% 0% 0% 100%
971Python 3 #2 14 min14 min7,7641228  1% 0% 0% 100%
1,492JavaScript V8 33.9433.9511,9361287  1% 0% 0% 100%
1,835Erlang HiPE #3 191.22191.2914,6761399  0% 0% 0% 100%
1,968JavaScript V8 #2 37.1037.1115,7441527  0% 0% 0% 100%
3,757Java  #2 22.6722.6830,0561424  0% 0% 1% 100%
3,832Dart #2 30.5030.5130,6561274  0% 0% 1% 100%
3,995Dart #3 28.0528.0631,9601420  1% 0% 1% 100%
4,157Racket #2 53.8253.8633,2561689  0% 1% 1% 100%
5,031C# Mono #6 24.5224.5240,2481289  0% 0% 1% 100%
5,032C# Mono #5 31.6531.6640,2521485  0% 0% 1% 100%
5,035C# Mono #2 22.7422.7440,2761410  0% 1% 0% 100%
5,058C# Mono #4 30.8630.8740,4641461  0% 0% 1% 100%
5,066C# Mono #3 21.8021.8140,5281305  0% 0% 1% 100%
5,072C# Mono #8 22.0622.0640,5721343  1% 0% 0% 100%
5,107C# Mono 38.0438.0540,8521403  0% 0% 1% 100%
5,246Racket 105.09105.1941,9641496  0% 1% 1% 100%
5,280C# Mono #7 28.1828.2042,2401539  0% 0% 1% 100%
5,824Scala 23.7123.7246,5881358  0% 1% 1% 100%
6,453Smalltalk VisualWorks 193.92193.9851,6241652  1% 1% 1% 100%
6,703F# Mono 26.4926.5053,6241259  1% 1% 0% 100%
8,348Clojure #2 28.0728.0866,7841440  0% 1% 1% 100%
8,705Clojure 27.4427.4669,6402324  1% 0% 1% 100%
14,659Hack #5 9 min9 min117,2681432  1% 1% 1% 100%
14,880Hack #3 21 min21 min119,0361080  1% 1% 1% 100%
15,519Hack 10 min10 min124,1521288  0% 1% 1% 100%
94,063Ruby JRuby #2 6 min6 min752,5001137  1% 1% 1% 100%
Java  Failed1424
"wrong" (different) algorithm / less comparable programs
190C++ g++ #2 14.0014.001,5202288
1,467JavaScript V8 #3 33.3033.3111,7321505

 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