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 6.07 944 1753 6.14 0% 0% 100% 1%
1.2 C gcc #8 7.30 8 1391 7.37 0% 0% 100% 1%
1.3 C++ g++ #2 7.70 1,792 1879 7.83 100% 0% 0% 1%
1.3 C++ g++ #9 7.92 1,116 1773 8.51 6% 1% 1% 100%
1.3 C++ g++ #7 8.05 1,800 1808 8.10 0% 0% 0% 100%
1.3 C++ g++ #3 8.06 1,800 1763 8.16 0% 0% 100% 1%
1.3 C++ g++ #8 8.06 1,116 1765 8.20 1% 0% 0% 100%
1.4 Fortran Intel #6 8.28 8 1524 8.43 0% 1% 1% 100%
1.4 C gcc #4 8.73 1,052 1490 8.86 0% 100% 0% 1%
1.5 Fortran Intel #5 9.10 8 1664 9.37 1% 2% 100% 0%
1.6 Ada 2012 GNAT #2 9.74 1,972 2617 10.05 0% 2% 1% 100%
2.2 C++ g++ #5 13.29 1,864 1749 14.05 100% 1% 3% 1%
2.2 Rust #2 13.47 944 1805 13.62 0% 0% 1% 100%
2.2 Rust #6 13.58 944 1790 13.72 0% 0% 100% 1%
2.6 Ada 2012 GNAT #5 15.63 1,972 2447 16.15 1% 0% 100% 2%
3.0 Rust #4 18.48 940 1803 18.59 0% 100% 0% 0%
3.2 Fortran Intel 19.53 8 1393 19.77 0% 1% 0% 100%
3.2 C++ g++ 19.71 1,116 1659 20.27 100% 1% 1% 1%
3.2 Fortran Intel #2 19.71 8 1500 19.92 0% 1% 100% 0%
3.3 C++ g++ #6 19.75 1,116 1668 20.08 0% 1% 1% 100%
3.3 Rust #5 20.01 944 2220 20.49 0% 100% 1% 1%
3.5 C gcc #3 21.12 1,116 1208 21.36 0% 0% 100% 1%
3.5 Go 21.25 1,588 1310 21.48 0% 1% 100% 0%
3.6 Fortran Intel #4 21.56 8 1179 21.87 0% 1% 100% 0%
3.6 OCaml 21.68 1,556 1251 21.91 0% 1% 0% 100%
3.6 C# aot #3 21.74 34,340 1305 22.01 1% 0% 0% 100%
3.6 C# .NET Core #3 21.82 33,956 1305 22.24 1% 1% 1% 100%
3.6 Chapel 21.85 5,508 962 22.10 100% 0% 0% 1%
3.6 Haskell GHC #2 21.87 4,364 1883 86.49 99% 100% 99% 98%
3.6 Java  #5 21.95 35,604 1429 22.75 2% 1% 100% 1%
3.6 Swift #4 22.03 12,268 1355 22.25 0% 0% 100% 1%
3.6 C# aot #8 22.06 34,356 1343 22.35 94% 0% 0% 7%
3.6 C# .NET Core #8 22.13 33,748 1343 22.36 1% 0% 0% 100%
3.6 Swift #5 22.13 6,712 1253 22.35 0% 1% 0% 100%
3.7 C# aot #7 22.21 34,828 1542 22.56 1% 0% 100% 1%
3.7 C# .NET Core #7 22.27 34,280 1542 22.87 0% 3% 100% 0%
3.7 Fortran Intel #3 22.36 8 1305 22.72 0% 1% 100% 1%
3.7 Free Pascal 22.36 8 1325 22.46 0% 100% 0% 0%
3.7 C# aot #4 22.47 35,236 1404 22.72 1% 0% 0% 100%
3.7 C# aot #2 22.48 34,448 1410 22.69 100% 0% 0% 1%
3.7 Julia #3 22.53 179,180 1541 23.14 100% 1% 1% 1%
3.7 C# .NET Core #2 22.54 33,684 1410 22.75 100% 1% 0% 0%
3.7 Free Pascal #2 22.75 8 1339 22.85 100% 0% 0% 0%
3.8 F# .NET Core #2 22.76 36,616 1381 23.42 100% 1% 2% 1%
3.8 Julia 22.81 174,144 1149 23.44 2% 1% 1% 100%
3.8 C# aot 22.89 34,512 1403 23.08 0% 100% 0% 0%
3.8 C# .NET Core 22.96 33,808 1403 23.40 1% 0% 1% 100%
3.8 C# .NET Core #4 22.97 34,892 1404 23.15 0% 100% 0% 0%
3.8 C gcc #7 23.01 1,116 1244 23.32 1% 100% 0% 0%
3.8 Node js #6 23.29 34,584 1268 23.68 0% 1% 1% 100%
3.9 Node js 23.37 33,956 1297 23.60 100% 0% 0% 1%
3.9 Swift #7 23.62 12,220 1445 23.93 1% 0% 0% 100%
3.9 C# aot #5 23.64 34,920 1534 24.07 1% 100% 0% 1%
3.9 C++ g++ #4 23.67 848 1428 23.91 0% 0% 1% 100%
3.9 C# .NET Core #5 23.69 34,464 1534 24.02 0% 1% 100% 0%
3.9 C gcc #5 23.82 848 1429 24.07 1% 100% 0% 0%
3.9 Haskell GHC 23.83 4,224 1706 94.35 99% 100% 99% 99%
3.9 Ada 2012 GNAT #3 23.85 2,036 1750 24.09 1% 0% 0% 100%
3.9 Swift #8 23.89 12,236 1346 24.04 100% 0% 0% 0%
4.0 Java #4 23.98 35,448 1489 24.37 1% 100% 1% 0%
4.0 C gcc 24.13 1,116 1173 24.29 0% 100% 1% 0%
4.0 F# .NET Core 24.27 46,504 1267 24.93 77% 4% 7% 15%
4.0 F# .NET Core #3 24.27 36,128 1617 24.53 1% 0% 0% 100%
4.0 C gcc #6 24.30 1,116 1180 24.87 0% 0% 2% 100%
4.0 Swift #6 24.31 6,764 1194 24.48 0% 0% 100% 0%
4.0 C# aot #6 24.51 34,292 1289 25.09 1% 100% 0% 1%
4.1 C# .NET Core #6 24.59 33,816 1289 25.51 2% 100% 2% 0%
4.1 TypeScript #3 24.62 34,488 1354 24.84 40% 60% 0% 1%
4.1 F# .NET Core #4 24.70 37,656 1354 25.01 100% 0% 0% 1%
4.1 Free Pascal #3 24.93 8 1435 25.25 0% 1% 1% 100%
4.1 Java #2 25.17 35,732 1424 25.53 100% 1% 0% 0%
4.2 Java #3 25.30 35,532 1430 25.96 0% 1% 100% 1%
4.2 C gcc #2 25.44 1,116 1263 25.75 0% 100% 1% 0%
4.2 Go #3 25.61 1,604 1200 25.89 0% 10% 91% 0%
4.3 Java 25.81 36,948 1430 26.20 0% 1% 1% 100%
4.3 Lisp SBCL #2 26.25 18,036 1403 26.63 1% 0% 0% 100%
4.4 Rust 26.40 880 1480 26.73 0% 100% 0% 1%
4.4 Rust #3 26.48 880 1540 26.77 0% 100% 1% 1%
4.4 Go #2 26.75 1,588 1215 26.97 0% 1% 0% 100%
4.5 Dart snapshot #3 27.47 80,128 1409 27.82 1% 0% 100% 0%
4.5 Node js #5 27.57 34,396 1193 27.81 100% 0% 0% 1%
4.6 Dart #3 27.65 115,356 1409 28.69 1% 1% 73% 28%
4.6 Node js #4 27.95 34,380 1279 28.23 1% 0% 0% 100%
4.7 Ada 2012 GNAT 28.28 1,976 1618 28.61 0% 1% 100% 0%
5.7 Swift #2 34.79 6,712 1192 35.35 0% 58% 1% 43%
5.8 Swift #9 34.92 13,744 1603 35.34 0% 0% 100% 1%
5.8 Node js #2 35.18 34,768 1537 35.52 0% 100% 1% 0%
5.9 Dart #2 35.89 111,692 1264 36.70 1% 1% 100% 1%
6.9 Lisp SBCL 41.59 18,016 1368 42.00 100% 0% 0% 1%
7.9 Julia #2 48.11 244,316 1078 48.81 0% 100% 0% 1%
8.3 Dart aot #3 50.49 17,348 1409 51.03 92% 0% 1% 9%
8.3 Dart exe #3 50.49 17,368 1409 51.37 1% 0% 100% 1%
9.2 Racket #2 55.55 38,116 1689 56.63 1% 0% 100% 1%
10 Dart snapshot #2 60.45 84,332 1264 61.34 1% 3% 97% 1%
10 Dart aot #2 62.75 17,364 1264 63.92 1% 45% 56% 0%
10 Dart exe #2 62.77 17,372 1264 63.56 1% 18% 83% 0%
15 Racket 90.25 41,160 1496 91.47 13% 70% 4% 14%
20 Racket CS 123.19 86,608 1496 124.83 0% 60% 40% 0%
22 Racket CS #2 131.52 88,376 1689 133.19 0% 33% 67% 0%
29 TypeScript #2 173.41 37,424 1463 176.38 11% 0% 0% 90%
29 TypeScript 174.62 36,228 1471 177.49 1% 0% 100% 1%
31 Java OpenJ9 #2 190.52 154,520 1424 194.98 4% 57% 1% 40%
32 Erlang HiPE #3 194.05 24,108 1399 196.23 100% 0% 0% 1%
32 Java OpenJ9 194.36 59,420 1430 197.01 100% 0% 0% 1%
32 Java OpenJ9 #3 196.13 180,700 1430 199.42 1% 1% 0% 100%
32 VW Smalltalk 196.18 55,120 1782 198.51 0% 100% 0% 1%
33 Java OpenJ9 #4 197.42 153,632 1489 201.14 61% 1% 0% 39%
33 Java OpenJ9 #5 199.13 166,852 1429 205.53 1% 97% 4% 2%
35 Pharo Smalltalk 209.78 103,396 1801 213.45 1% 13% 85% 4%
36 Swift #3 216.99 6,544 1204 220.13 0% 8% 0% 93%
38 JRuby #2 232.14 776,088 1137 247.84 49% 4% 2% 51%
51 PHP #3 5 min 8,040 1082 5 min 65% 16% 5% 16%
63 Ruby #2 6 min 15,760 1137 7 min 6% 100% 1% 6%
67 Lua #4 6 min 1,368 1305 6 min 0% 0% 1% 100%
73 Lua #2 7 min 1,416 1193 7 min 0% 100% 1% 1%
74 Lua 7 min 1,388 1201 7 min 0% 0% 2% 98%
121 Perl #2 12 min 6,292 1429 12 min 96% 0% 0% 4%
143 Python 3 14 min 8,176 1196 14 min 2% 20% 79% 0%
151 Python 3 #2 15 min 8,260 1242 15 min 93% 1% 1% 7%
723 Matz's Ruby #2 1h 13 min 4,084 1137 1h 13 min 65% 0% 0% 35%
C# .NET Core #9 Bad Output
C# aot #9 Bad Output