The Computer Language
Benchmarks Game

n-body

We accept something intermediate between chaos and rigidity — enough flex & slop & play to allow for Haskell programs that are not just mechanically translated from Fortran; enough similarity in the basic workloads & tested results.

Programming language advocates and curious programmers have contributed new programs and introduced newer techniques. Look at the slower simple sequential programs, and  look at the parallel programs written for multicore, and  look at the low-level programs written for SIMD. Always look at the source code.

× source secs mem gz busy cpu load
1.0 Rust #7 5.71 872 1753 5.79 0% 1% 100% 0%
1.3 C gcc #8 7.49 8 1391 7.56 0% 0% 100% 1%
1.4 C++ g++ #9 8.18 1,112 1773 8.24 100% 0% 0% 1%
1.5 Fortran Intel #6 8.28 8 1524 8.36 100% 1% 0% 0%
1.6 Ada 2012 GNAT #2 9.04 1,896 2617 9.32 1% 100% 3% 0%
1.6 Fortran Intel #5 9.10 8 1664 9.22 100% 1% 0% 0%
1.6 C++ g++ #3 9.31 1,784 1763 9.41 100% 0% 0% 1%
1.6 C gcc #4 9.37 1,108 1490 9.49 100% 1% 1% 0%
1.6 C++ g++ #7 9.37 1,784 1808 9.45 0% 1% 100% 0%
1.7 C++ g++ #8 9.48 1,108 1765 9.59 1% 0% 0% 100%
2.2 C++ g++ #5 12.30 1,784 1749 12.39 0% 100% 0% 0%
2.3 Rust 13.31 876 1480 13.62 0% 1% 1% 100%
2.4 Rust #2 13.70 876 1805 14.05 1% 100% 0% 1%
3.2 Ada 2012 GNAT #5 18.01 1,892 2447 18.29 0% 1% 1% 100%
3.2 Rust #4 18.55 872 1803 18.97 1% 0% 100% 1%
3.4 Fortran Intel 19.54 8 1393 19.70 1% 0% 100% 0%
3.4 C++ g++ 19.67 1,112 1659 19.84 0% 100% 1% 0%
3.4 Fortran Intel #2 19.70 8 1500 19.86 1% 0% 100% 0%
3.5 C++ g++ #6 20.11 1,104 1668 20.61 0% 100% 2% 0%
3.5 Rust #5 20.14 876 2220 20.52 0% 100% 0% 1%
3.5 Rust #6 20.20 936 1790 20.46 100% 1% 0% 0%
3.5 C gcc 20.26 1,108 1173 20.49 100% 0% 0% 0%
3.6 Rust #3 20.30 872 1540 20.60 1% 100% 0% 0%
3.6 C++ g++ #4 20.31 780 1428 20.43 0% 100% 0% 0%
3.6 C gcc #6 20.80 1,112 1180 20.94 0% 0% 0% 100%
3.7 Go #3 21.06 1,432 1200 21.29 0% 0% 100% 1%
3.7 Go 21.29 1,436 1310 21.70 100% 1% 1% 0%
3.8 C# .NET Core #7 21.45 36,580 1542 22.28 4% 0% 0% 100%
3.8 Fortran Intel #4 21.56 8 1179 21.86 0% 0% 1% 100%
3.8 C gcc #2 21.62 1,108 1263 21.82 1% 0% 0% 100%
3.8 OCaml 21.69 1,496 1251 22.18 0% 100% 2% 0%
3.8 C# .NET Core #5 21.78 36,408 1534 22.07 0% 1% 100% 0%
3.8 C# .NET Core #3 21.79 36,692 1305 21.99 0% 1% 100% 0%
3.8 Java  #5 21.94 35,588 1429 22.39 100% 0% 1% 1%
3.8 Java #4 21.95 35,368 1489 22.32 1% 1% 0% 100%
3.8 Haskell GHC #2 21.96 4,160 1883 86.83 98% 99% 98% 100%
3.9 Swift #4 22.03 13,420 1355 22.52 1% 1% 0% 100%
3.9 C# .NET Core #8 22.06 36,708 1343 22.31 0% 1% 100% 0%
3.9 Swift #5 22.20 6,980 1253 22.38 1% 0% 100% 0%
3.9 Go #2 22.29 1,432 1215 22.88 100% 1% 1% 0%
3.9 Julia #3 22.29 175,412 1541 23.56 3% 2% 1% 100%
3.9 Free Pascal 22.36 8 1325 22.46 0% 100% 0% 0%
3.9 Fortran Intel #3 22.36 8 1305 22.60 100% 1% 0% 0%
3.9 C# .NET Core #2 22.43 36,696 1410 22.86 100% 1% 1% 0%
3.9 C# .NET Core 22.50 36,708 1403 22.91 100% 1% 1% 0%
3.9 C# .NET Core #4 22.52 36,556 1404 22.82 0% 0% 100% 1%
4.0 C gcc #7 22.69 1,112 1244 22.92 0% 0% 100% 1%
4.0 Free Pascal #2 22.75 8 1339 22.85 100% 0% 0% 0%
4.0 Julia 22.86 169,720 1149 23.39 1% 100% 2% 0%
4.0 F# .NET Core #2 22.94 39,152 1381 23.33 1% 0% 1% 100%
4.1 Node js #6 23.22 33,828 1268 23.54 1% 0% 0% 100%
4.1 Node js 23.27 33,668 1297 23.49 0% 100% 0% 1%
4.1 C gcc #3 23.44 1,108 1208 23.71 1% 100% 0% 0%
4.1 Swift #7 23.62 13,472 1445 23.97 1% 1% 100% 0%
4.2 Ada 2012 GNAT #3 23.78 1,960 1750 24.08 100% 0% 1% 0%
4.2 C gcc #5 23.80 840 1429 23.96 0% 100% 0% 0%
4.2 Chapel 23.81 5,408 962 24.10 100% 0% 0% 1%
4.2 Haskell GHC 23.83 4,084 1706 94.36 99% 99% 100% 99%
4.2 Swift #8 23.89 13,460 1346 24.26 1% 100% 1% 0%
4.2 F# .NET Core #3 24.15 38,360 1617 24.58 0% 100% 2% 0%
4.3 Swift #6 24.36 6,852 1194 24.64 100% 0% 0% 1%
4.3 TypeScript #3 24.41 33,848 1354 24.75 0% 100% 1% 0%
4.3 C# .NET Core #6 24.64 36,696 1289 24.96 0% 100% 1% 0%
4.4 Free Pascal #3 24.93 8 1435 25.25 0% 1% 1% 100%
4.4 Java #2 24.95 35,232 1424 25.34 100% 1% 1% 0%
4.4 Java #3 24.95 35,420 1430 25.16 0% 100% 1% 0%
4.4 Java 25.05 36,384 1430 25.28 0% 0% 1% 100%
4.4 F# .NET Core 25.17 67,840 1267 25.54 3% 62% 37% 0%
4.5 Substrate VM #4 25.83 3,040 1489 25.98 0% 0% 1% 100%
4.6 Substrate VM #3 26.01 3,016 1430 26.39 100% 0% 1% 1%
4.6 Substrate VM 26.12 2,756 1430 26.46 100% 0% 1% 0%
4.6 Substrate VM #2 26.19 2,952 1424 26.48 1% 0% 0% 100%
4.6 Lisp SBCL #2 26.25 17,364 1403 26.74 0% 1% 1% 100%
4.8 Dart snapshot #3 27.41 76,020 1409 27.84 0% 100% 1% 0%
4.8 Node js #5 27.55 33,716 1193 28.00 0% 0% 100% 1%
4.9 Node js #4 27.76 33,784 1279 28.10 1% 0% 100% 1%
4.9 Ada 2012 GNAT 28.15 1,896 1618 28.32 0% 100% 0% 0%
4.9 Dart #3 28.20 126,116 1409 28.99 1% 99% 2% 1%
5.2 Substrate VM #5 29.89 3,012 1429 30.21 100% 0% 0% 1%
6.0 Swift #9 34.22 13,012 1603 34.67 1% 100% 0% 0%
6.0 Swift #2 34.54 6,936 1192 35.23 1% 1% 0% 100%
6.3 Node js #2 35.86 33,536 1537 36.23 1% 0% 0% 100%
7.2 Lisp SBCL 41.39 17,456 1368 41.81 1% 0% 0% 100%
7.4 Dart #2 42.46 127,388 1264 43.93 99% 2% 2% 0%
8.4 Julia #2 48.19 217,064 1078 49.23 100% 1% 1% 0%
9.1 Dart aot #3 51.88 15,092 1409 52.54 100% 0% 0% 1%
9.4 Racket #2 53.97 54,040 1689 55.05 100% 1% 1% 0%
11 Dart snapshot #2 62.78 80,528 1264 63.60 0% 1% 100% 0%
11 Dart aot #2 63.49 14,944 1264 64.23 99% 0% 1% 1%
16 Racket 88.95 48,524 1496 89.86 0% 100% 1% 0%
22 Racket CS 125.20 79,536 1496 126.65 0% 1% 100% 0%
22 Racket CS #2 126.21 79,788 1689 127.98 18% 82% 1% 0%
31 TypeScript 179.05 35,976 1471 182.66 1% 1% 1% 100%
31 TypeScript #2 179.22 37,416 1463 182.84 5% 13% 18% 66%
33 Truffle Ruby #2 189.12 519,668 1137 203.14 2% 100% 3% 3%
34 Erlang HiPE #3 195.59 22,960 1399 197.84 0% 1% 100% 0%
34 VW Smalltalk 196.11 54,408 1782 199.25 100% 0% 1% 0%
37 Pharo Smalltalk 210.50 79,264 1801 213.86 0% 1% 1% 100%
37 JRuby #2 213.29 778,612 1137 228.93 46% 3% 3% 55%
38 Swift #3 218.04 6,756 1204 220.53 0% 0% 1% 100%
55 PHP #3 5 min 8,032 1082 5 min 57% 0% 0% 43%
67 Ruby #2 6 min 15,760 1137 7 min 6% 100% 1% 6%
71 Lua #4 6 min 1,368 1305 6 min 0% 0% 1% 100%
78 Lua #2 7 min 1,416 1193 7 min 0% 100% 1% 1%
78 Lua 7 min 1,388 1201 7 min 0% 0% 2% 98%
121 Perl #2 11 min 5,608 1429 11 min 1% 0% 100% 0%
136 Python 3 12 min 7,844 1196 13 min 29% 0% 0% 72%
145 Python 3 #2 13 min 7,968 1242 13 min 1% 0% 0% 100%
  Matz's Ruby #2 1h 13 min 4,084 1137 1h 13 min 65% 0% 0% 35%
C# .NET Core #9 Bad Output