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++ #7 9.129.138761545  0% 0% 100% 1%
1.0C++ g++ #8 9.139.147961544  1% 100% 0% 0%
1.1C gcc #4 10.3810.397361490  0% 100% 1% 1%
1.2Fortran Intel #5 10.7510.765201659  1% 0% 100% 1%
1.4C++ g++ #5 12.4812.491,2081749  100% 0% 0% 1%
2.0Ada 2005 GNAT #5 18.0418.051,6322436  1% 0% 0% 100%
2.2C++ g++ #3 19.8719.881,2281763  1% 0% 0% 100%
2.2C++ g++ #6 20.1120.128081668  1% 2% 1% 100%
2.2C gcc 20.1920.197161173  0% 0% 100% 0%
2.2C++ g++ #4 20.3020.316281428  1% 0% 0% 100%
2.2Fortran Intel #2 20.5320.545241496  0% 1% 1% 100%
2.3C++ g++ 20.5720.588041659  0% 100% 1% 0%
2.3C gcc #6 20.5920.607881180  1% 0% 100% 0%
2.3Fortran Intel 20.9020.915201389  1% 0% 0% 100%
2.3C gcc #5 21.0721.085801429  1% 0% 0% 100%
2.3C gcc #3 21.3021.317841208  1% 100% 0% 0%
2.5Fortran Intel #4 22.6022.615201172  1% 0% 100% 1%
2.6C# Mono #2 23.3523.3638,6841410  0% 100% 1% 0%
2.6Scala 23.4523.4028,8321358  1% 1% 100% 1%
2.7Rust 24.2624.265,9881474  1% 0% 0% 100%
2.7Java  #2 24.3424.3124,1561424  1% 1% 1% 100%
2.7Ada 2005 GNAT 24.8224.831,7241608  1% 0% 0% 100%
2.8Fortran Intel #3 25.2225.235161299  0% 1% 100% 0%
2.8C gcc #2 25.2725.287281263  100% 0% 1% 0%
2.8Ada 2005 GNAT #3 25.5925.601,7121740  0% 0% 100% 0%
2.9F# Mono 26.1826.1946,6361259  0% 1% 1% 100%
2.9Haskell GHC #2 27.1026.373,6441874  100% 2% 1% 2%
3.2Haskell GHC 30.9329.1712,4001706  2% 100% 2% 2%
3.6Clojure 34.6033.2654,2762324  98% 2% 2% 3%
3.7Dart #2 34.0233.7421,4721274  1% 55% 45% 1%
3.8Pascal Free Pascal 34.6934.7081308  1% 0% 100% 0%
3.9Go 36.0336.011,6081310  0% 69% 31% 1%
4.0Clojure #2 38.1036.8354,6801440  98% 2% 3% 1%
4.1Pascal Free Pascal #2 37.2037.2281322  0% 1% 1% 100%
4.2Dart #3 38.6738.3321,5521420  1% 1% 1% 100%
4.2Lisp SBCL #2 38.4138.437,8521398  0% 1% 100% 0%
4.2C# Mono 38.7838.7939,0961403  1% 100% 0% 0%
5.0Lisp SBCL 46.0246.037,8521363  0% 0% 100% 0%
5.2Pascal Free Pascal #3 47.1847.1981418  0% 1% 1% 100%
6.1Racket #2 55.3255.3320,9281689  1% 43% 58% 0%
8.2OCaml 75.2375.256001239  1% 0% 0% 100%
13Racket 116.11116.1036,5361496  0% 100% 1% 1%
29Erlang HiPE #3 269.21269.3027,7761399  53% 1% 1% 47%
74PHP #3 11 min11 min2,5921082  0% 1% 1% 100%
83Ruby JRuby #2 12 min12 min275,5881137  27% 23% 24% 29%
108Python 3 #2 16 min16 min6,0801228  6% 100% 2% 7%
109Python 3 16 min16 min4,2401181  0% 0% 100% 1%
135Perl #2 20 min20 min2,5521401  1% 0% 0% 100%
163Ruby #2 24 min24 min5,0841137  22% 0% 79% 1%
C# Mono #8 Failed1343
C# Mono #5 Failed1485
C# Mono #3 Failed1305
C# Mono #7 Failed1539
C# Mono #6 Failed1289
C# Mono #4 Failed1461
Java  Failed1424
"wrong" (different) algorithm / less comparable programs
1.3C++ g++ #2 12.2912.301,2082288

 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