/mobile Handheld Friendly website

 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 gcc #4 9.329.334321490  1% 0% 0% 100%
1.1C++ g++ #3 10.0810.098321763  0% 0% 0% 100%
1.2C++ g++ #5 10.7910.808321749  0% 0% 0% 100%
1.6Ada 2005 GNAT #5 15.3815.391,5002427  0% 0% 0% 100%
2.1C++ g++ #6 19.3319.344321668  0% 0% 0% 100%
2.1C++ g++ 19.5819.594321659  0% 0% 0% 100%
2.1Fortran Intel #2 19.9519.965121496  0% 0% 0% 100%
2.2Fortran Intel 20.0620.065121389  0% 0% 0% 100%
2.2ATS #2 20.2820.284321920  0% 0% 0% 100%
2.2C++ g++ #4 20.6720.683761428  0% 0% 0% 100%
2.2C gcc #3 20.8420.854321208  0% 0% 0% 100%
2.2C gcc #6 20.9220.934321180  0% 0% 0% 100%
2.3C gcc 21.2621.274361173  0% 0% 0% 100%
2.3Fortran Intel #3 21.5321.545121299  0% 0% 0% 100%
2.4C# Mono #3 22.3722.3814,6641305  1% 0% 0% 100%
2.4Fortran Intel #4 22.4722.485121172  0% 0% 0% 100%
2.4C gcc #2 22.4722.484321263  0% 0% 0% 100%
2.4C# Mono #2 22.4822.4914,5961410  0% 0% 0% 100%
2.4Java 7  #2 22.5122.5217,0161424  0% 0% 0% 100%
2.5Haskell GHC #2 22.9322.942,2401874  0% 0% 0% 100%
2.5Ada 2005 GNAT #3 23.2723.281,5081740  0% 0% 0% 100%
2.5Scala 23.4923.5023,4881358  0% 0% 0% 100%
2.5C gcc #5 23.6823.693721429  0% 0% 0% 100%
2.6OCaml 23.8223.837121239  1% 0% 0% 100%
2.6C# Mono #6 24.1624.1614,6361289  0% 0% 0% 100%
2.8Ada 2005 GNAT 25.9125.921,5121608  0% 0% 0% 100%
2.8Lisp SBCL #2 26.5726.585,0481398  0% 0% 0% 100%
2.9Go 26.6226.641,2721310  0% 0% 0% 100%
2.9Clojure 26.9126.9245,2202162  0% 0% 0% 100%
2.9Haskell GHC 27.3827.392,2321695  0% 1% 0% 100%
3.2F# Mono 29.6529.6619,7161259  0% 0% 0% 100%
3.3C# Mono #5 30.6130.6215,2121485  0% 0% 0% 100%
3.3C# Mono #4 31.2331.2414,9001461  0% 0% 0% 100%
3.7C# Mono 34.3534.3614,5961403  0% 0% 0% 100%
3.7Pascal Free Pascal 34.7434.7581308  0% 0% 0% 100%
3.8Pascal Free Pascal #3 35.3835.3981418  0% 0% 0% 100%
3.9JavaScript V8 36.8436.857,3601287  0% 0% 0% 100%
4.0Pascal Free Pascal #2 36.9937.0181322  0% 0% 0% 100%
4.6Lisp SBCL 42.8042.815,0441363  0% 0% 0% 100%
4.6JavaScript V8 #2 43.3543.376,8521527  0% 1% 0% 100%
5.8Racket #2 54.3554.3925,2281689  0% 0% 0% 100%
8.9Dart #2 82.7482.8641,6361297  0% 0% 0% 100%
11Dart 97.8798.0041,6281689  0% 0% 0% 100%
11Racket 104.30104.3827,2401496  0% 0% 0% 100%
13Erlang HiPE #3 119.80119.8412,1081399  0% 0% 0% 100%
21Smalltalk VisualWorks 192.75192.8042,8801652  0% 0% 0% 100%
48Lua #4 7 min7 min1,0401305  0% 0% 0% 100%
51Lua #2 7 min7 min1,0401193  0% 0% 0% 100%
56Lua 8 min8 min1,0361201  0% 0% 0% 100%
56Ruby JRuby #2 8 min8 min602,3121137  0% 0% 0% 100%
71Ruby 2.0 #2 11 min11 min6,1721137  0% 0% 0% 100%
83PHP #3 12 min12 min3,2641082  0% 0% 0% 100%
98Python 3 15 min15 min6,2961181  0% 0% 0% 100%
111Perl #2 17 min17 min2,6201401  0% 0% 0% 100%
"wrong" (different) algorithm / less comparable programs
1.0C++ g++ #2 9.799.808282288
3.7JavaScript V8 #3 34.0634.076,9281505

 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