n-body benchmark N=50,000,000

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

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.

    sortsortsort 
  ×   Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1.0PHP #3 11 min11 min2,5841082  0% 0% 1% 100%
1.1Ruby JRuby #2 6 min6 min713,5801137  0% 1% 1% 100%
1.1Ruby #2 24 min24 min5,1241137  0% 1% 1% 100%
1.1Fortran Intel #4 22.6022.605201172  1% 0% 0% 100%
1.1C gcc 20.1820.197441173  1% 0% 0% 100%
1.1C CINT 20h 06 min20h 06 min5,2881173  0% 0% 0% 100%
1.1C gcc #6 20.5920.607841180  1% 0% 0% 100%
1.1Python 3 16 min16 min4,2321181  1% 0% 1% 100%
1.1Lua #2 9 min9 min8721193  0% 1% 1% 100%
1.1Lua 11 min11 min8721201  0% 1% 1% 100%
1.1C gcc #3 21.3021.317441208  1% 0% 0% 100%
1.1Python 3 #2 16 min16 min6,0081228  1% 1% 0% 100%
1.1OCaml 75.2175.236001239  1% 0% 1% 100%
1.2F# Mono 25.9725.9846,8881259  0% 1% 0% 100%
1.2C gcc #2 25.8325.847841263  1% 1% 0% 100%
1.2Dart #2 33.9433.9621,2441274  0% 0% 1% 100%
1.2JavaScript V8 42.9943.0113,1081287  1% 0% 0% 100%
1.2Fortran Intel #3 25.2125.225161299  1% 0% 0% 100%
1.2Lua #4 9 min9 min8721305  0% 0% 1% 100%
1.2Pascal Free Pascal 34.7134.7281308  0% 0% 0% 100%
1.2Go 23.0923.107641310  0% 1% 0% 100%
1.2Pascal Free Pascal #2 37.2037.2281322  1% 0% 0% 100%
1.3Scala 23.4423.4528,9801358  1% 0% 1% 100%
1.3Lisp SBCL 46.0246.037,8521363  0% 0% 1% 100%
1.3Fortran Intel 20.8820.895201389  1% 1% 0% 100%
1.3Lisp SBCL #2 38.4238.437,8521398  1% 0% 0% 100%
1.3Erlang HiPE #3 267.27267.3610,3641399  0% 1% 1% 100%
1.3Perl #2 19 min19 min2,2641401  0% 1% 1% 100%
1.3C# Mono 38.5738.5839,4961403  1% 1% 0% 100%
1.3C# Mono #2 23.1623.1638,7921410  2% 1% 1% 100%
1.3Pascal Free Pascal #3 47.1847.1981418  0% 0% 1% 100%
1.3Dart #3 38.5638.5821,2961420  0% 1% 0% 100%
1.3Java  #2 24.3224.3324,0361424  1% 0% 0% 100%
1.3C++ g++ #4 20.3020.316241428  1% 1% 0% 100%
1.3C gcc #5 21.0721.085681429  1% 0% 1% 100%
1.3Clojure #2 37.7837.7955,1081440  1% 0% 0% 100%
1.4Rust 24.5624.585,9681474  1% 0% 0% 100%
1.4C gcc #4 10.3410.357481490  1% 1% 0% 100%
1.4Fortran Intel #2 20.5320.545241496  0% 0% 0% 100%
1.4Racket 116.12116.2035,6601496  0% 1% 1% 100%
1.4JavaScript V8 #2 43.1343.1411,0961527  0% 0% 1% 100%
1.4C++ g++ #8 9.149.148721544  1% 1% 0% 100%
1.4C++ g++ #7 9.119.128721545  1% 0% 1% 100%
1.5Ada 2005 GNAT 24.8224.821,7121608  0% 1% 1% 100%
1.5Smalltalk VisualWorks 5 min5 min23,4521652  0% 0% 1% 100%
1.5C++ g++ 20.5420.558041659  1% 1% 0% 100%
1.5Fortran Intel #5 10.7410.745201659  1% 1% 1% 100%
1.5C++ g++ #6 20.1620.178081668  2% 1% 1% 100%
1.6Racket #2 55.5255.5422,1681689  1% 1% 1% 100%
1.6Haskell GHC 28.5528.562,2081706  0% 1% 0% 100%
1.6Ada 2005 GNAT #3 25.5925.601,6481740  1% 0% 0% 100%
1.6C++ g++ #5 12.4812.491,2001749  0% 1% 1% 100%
1.6C++ g++ #3 19.8719.871,1801763  1% 0% 0% 100%
1.7Haskell GHC #2 26.0726.082,2121874  1% 0% 0% 100%
2.1Clojure 34.4034.4153,8242324  1% 0% 0% 100%
2.3Ada 2005 GNAT #5 18.0618.071,5762436  1% 0% 0% 100%
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.4JavaScript V8 #3 33.3033.3111,0681505
2.1C++ g++ #2 12.2912.301,2282288

 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