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 940 1753 6.14 1% 100% 0% 0%
1.2 C gcc #8 7.49 8 1391 7.56 0% 0% 100% 1%
1.3 C++ g++ #9 8.18 1,112 1773 8.24 100% 0% 0% 1%
1.4 Fortran Intel #6 8.28 8 1524 8.37 100% 0% 0% 1%
1.5 Ada 2012 GNAT #2 9.04 1,896 2617 9.32 1% 100% 3% 0%
1.5 Fortran Intel #5 9.10 8 1664 9.17 1% 100% 0% 0%
1.5 C++ g++ #3 9.31 1,784 1763 9.41 100% 0% 0% 1%
1.5 C gcc #4 9.37 1,108 1490 9.49 100% 1% 1% 0%
1.5 C++ g++ #7 9.37 1,784 1808 9.45 0% 1% 100% 0%
1.6 C++ g++ #8 9.48 1,108 1765 9.59 1% 0% 0% 100%
2.0 C++ g++ #5 12.30 1,784 1749 12.39 0% 100% 0% 0%
2.2 Rust #2 13.47 940 1805 13.61 0% 0% 100% 1%
2.2 Rust 13.59 936 1480 13.83 1% 100% 0% 0%
3.0 Ada 2012 GNAT #5 18.01 1,892 2447 18.29 0% 1% 1% 100%
3.0 Rust #4 18.48 872 1803 18.90 1% 1% 1% 100%
3.2 Fortran Intel 19.53 8 1393 19.76 1% 0% 0% 100%
3.2 C++ g++ 19.67 1,112 1659 19.84 0% 100% 1% 0%
3.2 Fortran Intel #2 19.71 8 1500 19.87 0% 100% 0% 0%
3.3 Rust #5 19.88 872 2220 20.06 0% 0% 100% 0%
3.3 Rust #3 20.08 872 1540 20.38 100% 1% 1% 0%
3.3 C++ g++ #6 20.11 1,104 1668 20.61 0% 100% 2% 0%
3.3 C gcc 20.26 1,108 1173 20.49 100% 0% 0% 0%
3.3 C++ g++ #4 20.31 780 1428 20.43 0% 100% 0% 0%
3.4 Rust #6 20.33 872 1790 20.54 100% 1% 0% 0%
3.4 C gcc #6 20.80 1,112 1180 20.94 0% 0% 0% 100%
3.5 Go 21.25 1,588 1310 21.43 0% 100% 0% 0%
3.6 Fortran Intel #4 21.56 8 1179 21.70 1% 100% 0% 0%
3.6 C gcc #2 21.62 1,108 1263 21.82 1% 0% 0% 100%
3.6 OCaml 21.69 1,496 1251 22.18 0% 100% 2% 0%
3.6 C# .NET Core #3 21.82 33,956 1305 22.24 1% 1% 1% 100%
3.6 Haskell GHC #2 21.87 4,232 1883 86.49 100% 99% 98% 99%
3.6 Java  #5 21.91 35,356 1429 22.28 100% 0% 0% 1%
3.6 Swift #4 21.94 12,152 1355 27.62 100% 8% 12% 6%
3.6 C# .NET Core #8 22.13 33,748 1343 22.36 1% 0% 0% 100%
3.7 Swift #5 22.20 6,744 1253 22.37 0% 100% 0% 0%
3.7 C# .NET Core #7 22.27 34,280 1542 22.87 0% 3% 100% 0%
3.7 Julia #3 22.34 180,516 1541 23.22 2% 1% 2% 99%
3.7 Free Pascal 22.36 8 1325 22.46 0% 100% 0% 0%
3.7 Fortran Intel #3 22.36 8 1305 22.61 0% 100% 0% 1%
3.7 C# .NET Core #2 22.54 33,684 1410 22.75 100% 1% 0% 0%
3.7 C gcc #7 22.69 1,112 1244 22.92 0% 0% 100% 1%
3.8 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.91 175,116 1149 23.46 100% 1% 1% 1%
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 Java #4 23.25 35,304 1489 23.54 0% 1% 100% 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 C gcc #3 23.44 1,108 1208 23.71 1% 100% 0% 0%
3.9 Swift #7 23.62 12,160 1445 23.87 1% 100% 0% 0%
3.9 C# .NET Core #5 23.69 34,464 1534 24.02 0% 1% 100% 0%
3.9 Ada 2012 GNAT #3 23.78 1,960 1750 24.08 100% 0% 1% 0%
3.9 C gcc #5 23.80 840 1429 23.96 0% 100% 0% 0%
3.9 Haskell GHC 23.83 4,136 1706 94.40 100% 99% 99% 99%
3.9 Chapel 23.83 5,480 962 24.12 100% 1% 1% 0%
3.9 Swift #8 23.89 11,980 1346 24.24 1% 1% 100% 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 Swift #6 24.32 6,740 1194 24.71 100% 1% 0% 0%
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 Free Pascal #3 24.93 8 1435 25.25 0% 1% 1% 100%
4.1 Java #2 25.17 35,604 1424 25.39 0% 100% 0% 0%
4.2 Java #3 25.30 35,636 1430 25.66 0% 0% 100% 1%
4.2 Go #3 25.58 1,604 1200 25.94 0% 100% 1% 1%
4.3 Java 25.82 36,748 1430 26.32 1% 1% 1% 100%
4.3 Lisp SBCL #2 26.25 17,364 1403 26.74 0% 1% 1% 100%
4.4 Go #2 26.74 1,588 1215 26.94 100% 0% 0% 0%
4.5 Dart snapshot #3 27.48 77,700 1409 27.92 1% 0% 0% 100%
4.5 Node js #5 27.57 34,396 1193 27.81 100% 0% 0% 1%
4.6 Dart #3 27.69 125,588 1409 28.64 1% 2% 99% 1%
4.6 Node js #4 27.95 34,380 1279 28.23 1% 0% 0% 100%
4.6 Ada 2012 GNAT 28.15 1,896 1618 28.32 0% 100% 0% 0%
5.6 Dart snapshot #2 33.88 81,872 1264 34.46 1% 1% 1% 100%
5.7 Dart #2 34.61 125,436 1264 35.38 1% 99% 1% 1%
5.7 Swift #2 34.86 6,604 1192 35.18 1% 100% 0% 0%
5.8 Swift #9 34.95 13,728 1603 35.41 100% 1% 0% 0%
5.8 Node js #2 35.18 34,768 1537 35.52 0% 100% 1% 0%
6.8 Lisp SBCL 41.39 17,456 1368 41.81 1% 0% 0% 100%
8.0 Julia #2 48.32 221,836 1078 49.25 1% 99% 1% 1%
8.3 Dart aot #3 50.49 18,132 1409 51.01 0% 100% 1% 0%
8.9 Racket #2 53.97 54,040 1689 55.05 100% 1% 1% 0%
10 Dart aot #2 62.84 18,052 1264 63.45 100% 0% 0% 0%
15 Racket 88.95 48,524 1496 89.86 0% 100% 1% 0%
21 Racket CS 125.20 79,536 1496 126.65 0% 1% 100% 0%
21 Racket CS #2 126.21 79,788 1689 127.98 18% 82% 1% 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%
32 Java OpenJ9 #2 192.05 157,760 1424 194.50 0% 3% 75% 22%
32 Java OpenJ9 #3 194.22 155,796 1430 197.89 0% 1% 1% 100%
32 Java OpenJ9 194.65 59,936 1430 197.57 100% 1% 1% 0%
32 Erlang HiPE #3 195.59 22,960 1399 197.84 0% 1% 100% 0%
32 Java OpenJ9 #4 195.62 157,324 1489 199.25 100% 0% 1% 0%
32 VW Smalltalk 196.11 54,408 1782 199.25 100% 0% 1% 0%
33 Java OpenJ9 #5 197.44 174,584 1429 200.47 1% 0% 100% 1%
35 Pharo Smalltalk 210.50 79,264 1801 213.86 0% 1% 1% 100%
35 JRuby #2 213.29 778,612 1137 228.93 46% 3% 3% 55%
36 Swift #3 217.14 6,584 1204 219.42 0% 100% 0% 0%
52 PHP #3 5 min 8,032 1082 5 min 57% 0% 0% 43%
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%
114 Perl #2 11 min 5,608 1429 11 min 1% 0% 100% 0%
141 Python 3 14 min 8,160 1196 14 min 25% 76% 1% 1%
154 Python 3 #2 15 min 8,156 1242 15 min 1% 1% 0% 100%
723 Matz's Ruby #2 1h 13 min 4,084 1137 1h 13 min 65% 0% 0% 35%
C# .NET Core #9 Bad Output