The Computer Language
Benchmarks Game

n-body

program source code, command-line and measurements

× source secs mem gz cpu cpu load
1.0 Fortran Intel #6 8.16 8 1524 8.16 100% 0% 1% 0%
1.0 C++ g++ #3 8.24 1,924 1763 8.23 1% 0% 100% 1%
1.1 Ada 2005 GNAT #2 8.80 2,116 2617 8.79 1% 100% 0% 0%
1.1 C++ g++ #8 9.04 1,204 1544 9.04 0% 100% 0% 1%
1.1 Fortran Intel #5 9.10 8 1664 9.10 100% 1% 1% 0%
1.1 C gcc #4 9.22 1,228 1490 9.22 100% 1% 1% 0%
1.2 C++ g++ #7 9.42 1,188 1545 9.42 0% 1% 1% 100%
1.5 C++ g++ #5 12.42 1,980 1749 12.42 0% 100% 1% 0%
1.6 Rust 13.26 1,784 1480 13.25 3% 1% 100% 1%
1.6 Rust #2 13.35 1,756 1805 13.35 0% 100% 1% 0%
2.1 Ada 2005 GNAT #5 17.02 2,104 2447 17.02 1% 0% 0% 100%
2.2 Rust #4 18.33 1,720 1803 18.32 1% 0% 0% 100%
2.4 C++ g++ 19.65 1,208 1659 19.64 0% 0% 1% 100%
2.4 Fortran Intel 19.67 8 1393 19.66 100% 0% 1% 0%
2.4 Fortran Intel #2 19.71 8 1500 19.70 2% 100% 1% 0%
2.5 C gcc 20.10 1,180 1173 20.09 0% 0% 0% 100%
2.5 C++ g++ #4 20.29 868 1428 20.28 0% 0% 1% 100%
2.5 C gcc #5 20.34 828 1429 20.33 1% 0% 100% 0%
2.5 Rust #3 20.43 1,700 1540 20.43 100% 0% 1% 0%
2.5 C++ g++ #6 20.49 1,192 1668 20.49 0% 0% 1% 100%
2.5 Chapel 20.62 5,072 962 20.62 100% 0% 1% 0%
2.6 C gcc #6 21.01 1,172 1180 21.01 1% 0% 100% 0%
2.6 Go 21.37 1,536 1310 21.38 0% 0% 100% 0%
2.6 C# .NET Core #7 21.40 35,528 1542 21.40 0% 100% 1% 0%
2.6 Go #3 21.47 1,536 1200 21.47 0% 0% 100% 0%
2.7 OCaml 21.67 1,588 1251 21.67 61% 1% 0% 39%
2.7 Fortran Intel #4 21.69 8 1179 21.68 1% 0% 100% 1%
2.7 C# .NET Core #5 21.73 35,592 1534 21.73 0% 100% 1% 0%
2.7 C# .NET Core #3 21.74 35,500 1305 21.74 1% 1% 1% 100%
2.7 C gcc #2 21.80 1,172 1263 21.80 1% 0% 0% 100%
2.7 Haskell GHC #2 21.91 4,068 1883 21.91 100% 1% 0% 0%
2.7 C# .NET Core #8 22.01 35,580 1343 22.02 1% 100% 2% 1%
2.7 Java  #4 22.17 33,128 1489 22.26 0% 100% 2% 0%
2.7 Swift #5 22.28 4,784 1253 22.27 0% 100% 2% 0%
2.7 Free Pascal 22.35 8 1325 22.34 0% 0% 0% 100%
2.7 C# .NET Core #2 22.37 35,468 1410 22.37 1% 0% 1% 100%
2.7 Java #2 22.39 33,188 1424 22.48 3% 1% 99% 1%
2.7 Fortran Intel #3 22.42 8 1305 22.41 0% 100% 0% 0%
2.8 C# .NET Core 22.45 35,528 1403 22.46 1% 100% 2% 0%
2.8 Go #2 22.46 1,536 1215 22.46 1% 0% 0% 100%
2.8 C# .NET Core #4 22.47 35,496 1404 22.48 1% 0% 100% 1%
2.8 Kotlin #2 22.55 32,788 1390 22.64 0% 1% 1% 100%
2.8 Java 22.73 34,116 1430 22.84 100% 1% 0% 1%
2.8 Free Pascal #2 22.74 8 1339 22.74 100% 1% 0% 0%
2.8 Java #3 22.78 32,836 1430 22.87 1% 1% 1% 100%
2.8 F# .NET Core #2 22.89 37,872 1381 22.89 0% 100% 1% 0%
2.8 Kotlin #5 23.08 33,068 1349 23.18 1% 99% 1% 1%
2.9 Java #5 23.40 33,284 1429 23.50 1% 100% 0% 1%
2.9 C gcc #3 23.44 1,204 1208 23.44 1% 0% 100% 0%
2.9 Ada 2005 GNAT #3 23.57 2,096 1750 23.56 1% 0% 0% 100%
2.9 Swift #6 24.04 7,316 1194 24.03 0% 100% 1% 0%
3.0 F# .NET Core #3 24.10 37,136 1617 24.11 100% 0% 0% 0%
3.0 Ada 2005 GNAT 24.11 2,144 1618 24.11 1% 0% 25% 75%
3.0 C# .NET Core #6 24.60 35,484 1289 24.60 100% 1% 1% 1%
3.1 Free Pascal #3 24.92 8 1435 24.91 0% 0% 0% 100%
3.1 F# .NET Core 25.11 68,108 1267 25.14 0% 66% 35% 0%
3.1 Haskell GHC 25.34 4,120 1706 100.24 99% 98% 100% 99%
3.2 Node js 26.35 34,068 1297 26.35 100% 0% 0% 0%
3.3 Java AOT 26.69 5,516 1430 26.68 0% 1% 100% 0%
3.3 Lisp SBCL #2 27.13 17,668 1403 27.12 100% 1% 0% 0%
3.3 TypeScript #3 27.22 32,840 1348 27.22 100% 1% 0% 0%
3.4 Java AOT #2 27.57 5,516 1424 27.56 0% 2% 100% 0%
3.4 Java AOT #3 27.71 5,496 1430 27.71 2% 100% 1% 0%
3.4 Dart #3 27.99 32,400 1426 28.04 1% 1% 0% 100%
3.5 Java AOT #4 28.24 5,568 1489 28.23 0% 0% 1% 100%
3.6 Node js #5 29.15 33,404 1193 29.15 100% 1% 0% 0%
3.7 Java AOT #5 29.93 5,568 1429 29.92 100% 0% 1% 0%
3.9 Node js #4 31.64 33,632 1279 31.64 100% 1% 1% 0%
3.9 Swift #2 31.70 7,184 1192 31.69 0% 100% 1% 0%
4.1 Dart #2 33.32 30,844 1278 33.36 1% 80% 20% 0%
4.9 Node js #2 39.92 33,472 1537 39.92 33% 1% 0% 67%
5.2 Truffle Ruby #2 42.02 336,436 1137 58.11 15% 14% 13% 96%
5.2 Lisp SBCL 42.53 17,668 1368 42.52 0% 83% 19% 0%
6.6 Racket #2 53.89 26,192 1689 53.89 0% 0% 0% 100%
13 Racket 108.53 26,300 1496 108.50 0% 1% 100% 0%
14 TypeScript 115.45 46,436 1462 117.74 1% 72% 29% 1%
15 TypeScript #2 121.05 45,056 1453 123.55 33% 6% 3% 63%
23 Erlang HiPE #3 187.50 21,696 1399 187.50 45% 56% 0% 0%
24 VW Smalltalk 193.54 54,728 1824 193.47 1% 59% 1% 42%
25 Swift #3 206.42 4,448 1204 206.38 0% 1% 100% 0%
43 PHP #3 5 min 9,220 1082 5 min 0% 100% 1% 0%
50 Lua #4 6 min 1,404 1305 6 min 0% 98% 3% 0%
50 JRuby #2 6 min 804,512 1137 7 min 24% 43% 12% 26%
52 Lua #2 7 min 1,412 1193 7 min 0% 100% 1% 0%
56 Lua 7 min 1,488 1201 7 min 0% 100% 1% 0%
77 Hack #5 10 min 116,640 1439 10 min 5% 89% 1% 6%
79 Ruby #2 10 min 8,848 1137 10 min 8% 93% 0% 0%
87 Perl #2 11 min 5,244 1429 11 min 0% 1% 0% 100%
103 Python 3 13 min 10,324 1196 13 min 95% 1% 5% 0%
110 Python 3 #2 14 min 10,384 1242 14 min 19% 27% 55% 0%
217 Hack #3 29 min 115,996 1080 29 min 11% 90% 0% 1%
544 Matz's Ruby #2 1h 13 min 3,856 1137 1h 13 min 0% 0% 99% 1%
C# .NET Core #9 Bad Output
Swift #7 Failed
Swift #8 Failed
Swift #4 Failed