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 2012 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.17 1,228 1490 9.17 100% 0% 0% 1%
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 #2 13.13 1,740 1805 13.12 1% 100% 0% 1%
1.7 Rust 13.52 1,760 1480 13.51 2% 0% 100% 0%
2.1 Ada 2012 GNAT #5 17.02 2,104 2447 17.02 1% 0% 0% 100%
2.3 Rust #4 18.53 1,784 1803 18.53 1% 100% 0% 0%
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,220 1173 20.09 1% 0% 0% 100%
2.5 C++ g++ #4 20.29 868 1428 20.28 0% 0% 1% 100%
2.5 Rust #5 20.29 1,792 2220 20.28 1% 0% 100% 0%
2.5 C gcc #5 20.34 828 1429 20.33 1% 0% 100% 0%
2.5 Rust #3 20.46 1,784 1540 20.45 1% 0% 100% 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.02 1,220 1180 21.01 0% 0% 100% 1%
2.6 Go 21.37 1,536 1310 21.38 0% 0% 100% 0%
2.6 C# .NET Core #7 21.39 35,852 1542 21.40 100% 1% 1% 1%
2.6 Go #3 21.47 1,536 1200 21.47 0% 0% 100% 0%
2.7 OCaml 21.67 1,524 1251 21.67 1% 0% 0% 100%
2.7 Fortran Intel #4 21.69 8 1179 21.68 1% 0% 100% 1%
2.7 C# .NET Core #3 21.72 35,748 1305 21.72 100% 0% 0% 1%
2.7 C# .NET Core #5 21.73 35,864 1534 21.73 0% 100% 1% 0%
2.7 C gcc #2 21.80 1,216 1263 21.80 0% 100% 0% 1%
2.7 C# .NET Core #8 21.86 35,856 1343 21.87 3% 1% 0% 100%
2.7 Haskell GHC #2 21.91 4,068 1883 21.91 100% 1% 0% 0%
2.7 Java  #4 22.19 33,272 1489 22.28 35% 2% 66% 1%
2.7 Swift #5 22.28 7,388 1253 22.27 0% 1% 100% 0%
2.7 Free Pascal 22.36 8 1325 22.35 100% 1% 2% 1%
2.7 C# .NET Core #2 22.36 35,788 1410 22.37 45% 1% 1% 56%
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,824 1403 22.45 1% 0% 1% 100%
2.8 Go #2 22.46 1,536 1215 22.46 1% 0% 0% 100%
2.8 C# .NET Core #4 22.47 35,816 1404 22.47 100% 1% 1% 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.75 8 1339 22.75 100% 0% 0% 1%
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,140 1208 23.44 0% 0% 100% 1%
2.9 Ada 2012 GNAT #3 23.57 2,096 1750 23.56 1% 0% 0% 100%
2.9 Swift #6 24.04 7,248 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 2012 GNAT 24.11 2,144 1618 24.11 1% 0% 25% 75%
3.0 C# .NET Core #6 24.60 35,832 1289 24.60 100% 0% 0% 1%
3.1 Free Pascal #3 24.92 8 1435 24.92 100% 0% 0% 1%
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 33,228 1297 26.35 1% 0% 100% 0%
3.3 Java AOT 26.69 5,516 1430 26.68 0% 1% 100% 0%
3.3 TypeScript #3 26.96 32,432 1348 26.96 3% 100% 7% 4%
3.3 Lisp SBCL #2 27.13 17,764 1403 27.12 0% 100% 0% 1%
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.5 Java AOT #4 28.24 5,568 1489 28.23 0% 0% 1% 100%
3.5 Dart #3 28.41 129,076 1409 28.88 5% 44% 2% 52%
3.6 Node js #5 29.16 32,908 1193 29.16 100% 0% 0% 0%
3.7 Java AOT #5 29.93 5,568 1429 29.92 100% 0% 1% 0%
3.9 Node js #4 31.63 32,940 1279 31.63 100% 0% 0% 1%
3.9 Swift #2 31.74 7,132 1192 31.73 0% 100% 0% 0%
4.6 Node js #2 37.46 32,844 1537 37.46 100% 1% 0% 0%
4.7 Dart #2 38.19 131,396 1264 38.64 1% 1% 99% 1%
5.2 Truffle Ruby #2 42.02 336,436 1137 58.11 15% 14% 13% 96%
5.2 Lisp SBCL 42.61 17,764 1368 42.60 100% 0% 0% 1%
6.6 Racket #2 53.89 26,192 1689 53.89 0% 0% 0% 100%
10 TypeScript 85.59 44,084 1462 86.64 1% 1% 63% 38%
11 TypeScript #2 88.59 42,652 1453 90.07 53% 47% 2% 1%
13 Racket 108.53 26,300 1496 108.50 0% 1% 100% 0%
23 Erlang HiPE #3 188.59 23,660 1399 188.61 53% 0% 1% 48%
24 VW Smalltalk 193.54 54,728 1824 193.47 1% 59% 1% 42%
25 Swift #3 206.46 4,420 1204 206.42 0% 100% 0% 0%
43 PHP #3 5 min 9,220 1082 5 min 0% 100% 1% 0%
44 Ruby #2 5 min 12,284 1137 6 min 8% 95% 5% 5%
50 Lua #4 6 min 1,404 1305 6 min 0% 98% 3% 0%
52 Lua #2 7 min 1,412 1193 7 min 0% 100% 1% 0%
53 JRuby #2 7 min 793,604 1137 7 min 50% 4% 42% 8%
56 Lua 7 min 1,488 1201 7 min 0% 100% 1% 0%
78 Hack #5 10 min 132,720 1439 10 min 1% 100% 1% 0%
87 Perl #2 11 min 5,244 1429 11 min 0% 1% 0% 100%
108 Python 3 14 min 8,212 1196 14 min 91% 0% 1% 9%
115 Python 3 #2 15 min 8,272 1242 15 min 32% 0% 0% 69%
218 Hack #3 29 min 132,388 1082 29 min 24% 1% 6% 72%
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