The Computer Language
24.09 Benchmarks Game

n-body

First, here are a few naive un-optimised single-thread programs transliterated into different programming languages from the same original —

  source secs mem gz    
  Swift #8 6.65 19,440 1285    
  C# .NET #8 7.25 25,260 1335    
  Dart #8 7.49 19,436 1268    
  Java #8 7.59 42,924 1322    
  Go #8 9.60 19,436 1224    
  Node.js #8 9.74 52,352 1173    
  PHP #8 65.86 19,440 1245    
  Java -Xint #8 160.65 37,692 1322    
  Ruby yjit #8 6 min 21,376 1160    
  Python 3 #8 8 min 19,312 1172    
 
 
  Here are the crowd sourced programs —  
 
 
× source secs mem gz cpu secs cpu load
1.0 Intel Fortran #5 3.39 19,648 1669 3.39 1% 0% 100% 0%
1.1 Chapel #3 3.86 19,436 983 3.87 100% 0% 0% 0%
1.2 Rust #2 3.94 19,804 1809 3.94 0% 100% 0% 0%
1.2 Julia #8 3.97 278,400 1129 4.35 96% 6% 0% 8%
1.3 Rust #6 4.30 19,804 1796 4.30 100% 0% 0% 0%
1.3 Chapel #4 4.34 19,436 1027 4.34 100% 0% 0% 0%
1.3 Intel Fortran #2 4.46 19,776 1507 4.46 0% 0% 100% 0%
1.3 Rust #8 4.49 19,804 1774 4.49 100% 0% 0% 0%
1.3 Intel Fortran 4.55 19,648 1400 4.55 0% 0% 41% 59%
1.4 Intel Fortran #3 4.71 19,648 1311 4.71 100% 0% 0% 0%
1.5 C gcc #6 4.97 19,684 1186 4.97 100% 0% 0% 0%
1.5 Intel Fortran #6 5.01 19,648 1530 5.01 0% 0% 100% 0%
1.5 Rust #4 5.10 19,804 1810 5.10 62% 37% 0% 0%
1.5 C gcc 5.18 19,684 1179 5.18 0% 0% 100% 0%
1.5 C gcc #2 5.20 19,684 1270 5.20 0% 0% 100% 0%
1.5 C gcc #3 5.24 19,684 1214 5.24 100% 0% 0% 0%
1.6 C++ g++ #3 5.31 19,736 1402 5.31 100% 0% 0% 0%
1.6 Swift #3 5.43 19,440 1688 5.43 1% 0% 0% 99%
1.6 C++ g++ #9 5.44 19,736 1536 5.44 0% 100% 0% 0%
1.6 Rust 5.51 19,804 1483 5.51 0% 100% 0% 0%
1.6 Rust #3 5.57 19,804 1546 5.57 0% 0% 100% 0%
1.7 Chapel #2 5.67 19,436 977 5.67 99% 0% 0% 0%
1.7 Swift #6 5.78 19,440 1213 5.78 99% 0% 0% 0%
1.7 Ada 2012 GNAT #3 5.87 19,568 1758 5.86 0% 0% 0% 100%
1.8 C++ g++ #5 6.02 19,736 1544 6.01 100% 0% 0% 0%
1.9 Free Pascal 6.29 19,672 1331 6.29 0% 0% 100% 0%
1.9 Free Pascal #2 6.29 19,672 1345 6.29 0% 0% 0% 100%
1.9 Julia #4 6.33 278,596 1168 6.72 37% 64% 0% 5%
1.9 Go #3 6.38 19,808 1207 6.40 0% 100% 0% 0%
1.9 Haskell GHC #2 6.39 19,808 1888 6.48 0% 0% 0% 99%
1.9 C# .NET #0 6.44 26,464 1342 6.43 0% 99% 0% 0%
1.9 C++ g++ 6.50 19,736 1666 6.50 0% 100% 0% 0%
1.9 C++ g++ #8 6.54 19,736 1524 6.54 0% 0% 99% 0%
2.0 C# .NET #3 6.65 31,492 1311 6.64 99% 0% 0% 0%
2.0 Swift #8 6.65 19,440 1285 6.65 3% 1% 0% 97%
2.0 C gcc #7 6.82 19,684 1250 6.82 84% 0% 0% 16%
2.0 C# .NET #2 6.83 26,012 1339 6.82 0% 0% 0% 99%
2.0 Java  #4 6.88 42,028 1495 6.91 1% 0% 99% 0%
2.0 F# .NET #4 6.89 33,992 1296 6.88 99% 0% 0% 0%
2.0 C++ g++ #6 6.91 19,736 1674 6.91 0% 100% 0% 1%
2.0 F# .NET #3 6.92 32,372 1624 6.91 0% 0% 99% 0%
2.0 OCaml 6.94 19,676 1255 6.94 0% 100% 0% 0%
2.1 Dart #6 6.97 19,808 1318 6.97 0% 0% 99% 0%
2.1 Go 7.01 19,808 1316 7.03 100% 0% 0% 0%
2.1 Go #2 7.03 19,808 1222 7.05 100% 0% 0% 0%
2.1 Free Pascal #3 7.18 19,672 1441 7.18 100% 0% 0% 0%
2.1 Julia #3 7.22 281,680 1548 7.61 99% 1% 4% 1%
2.1 C# .NET #8 7.25 25,260 1335 7.25 0% 0% 99% 0%
2.2 Java #5 7.30 43,424 1435 7.36 0% 99% 0% 0%
2.2 F# .NET #2 7.42 34,040 1387 7.41 99% 0% 0% 0%
2.2 Java #2 7.48 42,260 1430 7.52 0% 0% 99% 0%
2.2 Java #3 7.49 42,292 1436 7.52 0% 0% 99% 0%
2.2 Dart #8 7.49 19,436 1268 7.49 46% 0% 0% 54%
2.2 Java #8 7.59 42,924 1322 7.64 0% 99% 0% 0%
2.3 Ada 2012 GNAT 7.64 19,568 1624 7.64 100% 0% 0% 0%
2.3 F# .NET 7.77 49,464 1272 7.83 0% 0% 0% 99%
2.3 C# .NET 7.80 31,508 1424 7.79 99% 0% 0% 0%
2.3 Lisp SBCL #2 7.80 23,168 1408 7.80 0% 0% 100% 0%
2.3 Java 7.84 42,652 1437 7.88 99% 0% 0% 0%
2.3 Swift 7.85 19,440 1210 7.85 14% 0% 85% 0%
2.5 Node.js #6 8.63 52,224 1274 8.63 71% 0% 29% 0%
2.6 Dart #2 8.90 19,808 1273 8.90 0% 100% 0% 0%
2.7 Lisp SBCL 9.25 23,168 1373 9.25 0% 100% 0% 0%
2.8 Go #8 9.60 19,436 1224 9.62 0% 0% 100% 0%
2.9 Node.js #8 9.74 52,352 1173 9.75 0% 99% 0% 0%
3.3 Dart #3 11.07 19,808 1413 11.07 0% 99% 0% 0%
8.3 Julia #2 28.24 299,868 1084 28.71 1% 0% 0% 99%
12 Racket 40.63 77,432 1503 40.62 0% 0% 100% 0%
19 PHP #8 65.86 19,440 1245 65.85 12% 87% 0% 0%
20 PHP #3 66.53 19,804 1088 66.52 0% 0% 0% 100%
31 Erlang #3 104.40 55,560 1405 104.46 0% 0% 0% 99%
32 VW Smalltalk 108.66 55,424 1787 108.65 0% 0% 100% 0%
55 Ruby yjit #3 186.79 20,864 1169 186.79 100% 0% 0% 0%
64 Ruby yjit #2 215.78 20,864 1143 215.77 0% 98% 2% 0%
65 Lua #2 220.08 19,656 1200 220.07 0% 0% 0% 100%
66 Lua #4 223.32 19,656 1312 223.30 100% 0% 0% 0%
77 Lua 262.10 19,656 1207 262.08 100% 0% 0% 0%
85 Swift #9 288.23 19,440 1532 288.20 71% 10% 4% 13%
105 Python 3 5 min 19,312 1201 5 min 97% 0% 0% 2%
111 Python 3 #2 6 min 19,312 1247 6 min 0% 100% 0% 0%
115 Ruby yjit #8 6 min 21,376 1160 6 min 0% 0% 0% 100%
131 Perl #2 7 min 19,688 1431 7 min 97% 0% 2% 0%
153 Python 3 #8 8 min 19,312 1172 8 min 100% 0% 0% 0%
208 Ruby yjit #7 11 min 21,120 1139 11 min 55% 0% 0% 45%
  Matz's Ruby #2 43 min 19,860 1143 43 min 100% 0% 0% 0%
  Matz's Ruby #3 43 min 19,684 1169 43 min 0% 0% 100% 0%
  Matz's Ruby #8 54 min 19,436 1160 54 min 0% 100% 0% 0%
Intel Fortran #4 Bad Output
Matz's Ruby #7 Failed
 
 
  hand-written vector instructions | "unsafe"
 
× source secs mem gz cpu secs cpu load
0.6 C gcc #9 2.10 19,704 1639 2.10 0% 0% 100% 1%
0.6 C++ g++ #0 2.15 19,736 1933 2.15 100% 0% 0% 0%
0.6 Rust #9 2.19 19,804 1881 2.19 0% 100% 0% 0%
0.9 C# .NET #9 3.16 30,388 2480 3.16 0% 99% 0% 0%
1.0 Rust #7 3.25 19,804 1759 3.24 0% 0% 100% 0%
1.1 C# .NET #4 3.75 30,516 2137 3.74 0% 0% 0% 99%
1.2 C++ g++ #7 3.96 19,736 1815 3.96 0% 0% 100% 1%
1.2 C++ g++ #2 4.20 19,736 1884 4.20 100% 1% 0% 0%
1.3 C gcc #4 4.31 19,684 1496 4.31 100% 0% 0% 0%
1.4 C# .NET #7 4.79 30,640 1715 4.79 0% 99% 0% 0%
1.4 C# .NET #6 4.82 30,640 1754 4.81 0% 99% 1% 0%
1.5 F# .NET #6 4.97 33,856 1395 4.96 0% 0% 99% 0%
1.5 Rust #5 5.01 19,804 2224 5.01 0% 100% 0% 0%
1.6 C gcc #5 5.43 19,684 1436 5.43 100% 0% 0% 0%
1.6 C++ g++ #4 5.45 19,736 1434 5.45 0% 26% 0% 73%
1.6 Swift #4 5.46 19,440 1361 5.46 0% 0% 0% 100%
1.6 Swift #5 5.49 19,440 1372 5.49 0% 0% 0% 100%
1.6 Swift #7 5.50 19,440 1333 5.50 0% 0% 0% 100%
1.7 F# .NET #5 5.74 33,780 1363 5.73 99% 1% 0% 0%
2.1 Haskell GHC 7.19 19,808 1713 7.29 0% 0% 99% 0%
2.7 Ada 2012 GNAT #5 9.00 19,568 2452 9.00 100% 0% 0% 0%
3.0 Ada 2012 GNAT #2 10.15 19,568 2623 10.14 0% 0% 0% 100%
4.1 Racket #2 14.04 77,392 1695 14.04 0% 100% 0% 0%