Skip to content

Language Shootout

A user-supported site Fastest, Shortest, Simplest

Benchmarks

N-Body

Background

Model the orbits of Jovian planets, using the same simple symplectic-integrator.

Thanks to Mark C. Lewis for suggesting this task.

Useful symplectic integrators are freely available, for example the HNBody Symplectic Integration Package.

How to implement

We ask that contributed programs not only give the correct result, but also use the same algorithm to calculate that result.

Each program should:

  • Use the same simple symplectic-integrator - see the Java program.

Verification: Use ndiff -abserr 1.0e-8 to compare program output with N=1000 against the reference output.

Use a larger command line argument (50000000) to check program performance.

Times are wall-clock milliseconds, with this implementation’s hello-world startup time subtracted. gz is the source in bytes with comments removed and gzipped. style is the idiomatic-code score. Click a heading to sort.

# source ms cpu ms mem KB gz style by
1 Fortran gfortran #1 1,572.5 1,564.9 7,388 1,355 ★★★☆☆ sysop-
2 Kotlin JVM #1 2,044.0 2,062.7 45,792 1,393 ★★★☆☆ sysop-
3 C# dotnet #1 2,093.9 2,078.3 26,588 1,453 ★★★★☆ sysop-
4 Erlang #1 48,112.7 47,982.6 42,244 1,389 ★★★☆☆ sysop-