The Computer Language
22.05 Benchmarks Game

Fastest cpu secs C++ g++ versus Java

Always look at the source code.

If the fastest programs are hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more cpu seconds, less gz source code.

fannkuch-redux
source mem gz cpu
C++ g++ #6 2,000 1528 12.93
C++ g++ #7 992 1150 13.89
C++ g++ #5 2,000 980 29.40
C++ g++ #4 2,216 1439 40.52
C++ g++ #3 988 593 40.55
Java #3 35,324 1257 41.17
Java 35,824 1282 41.74
C++ g++ #2 2,224 1440 42.64
C++ g++ 2,164 1059 42.76
Java #2 34,244 514 44.98
n-body
source mem gz cpu
C++ g++ #0 964 1927 2.17
C++ g++ #2 1,944 1879 4.06
C++ g++ #7 1,976 1808 4.28
C++ g++ #9 1,260 1530 4.90
C++ g++ #6 1,300 1668 5.65
C++ g++ #4 1,040 1428 5.68
C++ g++ #3 1,280 1396 5.74
C++ g++ 1,260 1659 5.93
C++ g++ #8 1,220 1517 6.08
C++ g++ #5 1,944 1749 6.11
Java #5 34,252 1429 6.79
Java #4 34,076 1489 6.79
Java #3 34,612 1430 7.50
Java #2 34,704 1424 7.50
Java 37,380 1430 7.83
spectral-norm
source mem gz cpu
C++ g++ #6 1,348 1044 2.85
C++ g++ #5 2,048 1044 5.26
C++ g++ 1,964 452 5.36
Java #3 38,428 756 5.94
C++ g++ #8 1,348 1278 6.09
Java 37,288 514 9.76
Java #2 37,368 950 10.07
mandelbrot
source mem gz cpu
C++ g++ #4 34,720 3542 3.27
C++ g++ 32,336 1791 3.48
C++ g++ #6 31,792 1002 3.88
C++ g++ #0 34,712 2739 4.06
C++ g++ #8 34,448 742 13.19
C++ g++ #5 33,640 590 13.37
C++ g++ #9 34,428 726 13.48
C++ g++ #7 34,392 1017 13.92
Java #4 66,304 660 16.16
Java #2 68,860 796 16.21
Java #6 67,432 802 16.92
C++ g++ #2 34,176 692 17.47
Java 34,252 665 27.75
C++ g++ #3 1,976 414 28.53
Java #3 69,200 903 29.18
pidigits
source mem gz cpu
C++ g++ #4 4,220 513 0.71
C++ g++ #5 4,284 798 0.72
Java #3 35,700 764 0.82
Java #2 38,328 938 1.53
Java 513,728 800 8.94
regex-redux
source mem gz cpu
C++ g++ #6 275,924 2850 2.20
C++ g++ #4 203,888 1315 3.39
C++ g++ 207,788 656 3.57
C++ g++ #2 198,316 700 3.69
C++ g++ #5 214,888 852 4.28
Java 924,116 868 17.12
Java #6 728,332 740 17.16
Java #3 741,028 929 17.34
C++ g++ #3 217,248 853 18.28
fasta
source mem gz cpu
C++ g++ #8 2,720 2751 1.52
C++ g++ #2 2,004 1127 1.85
C++ g++ 2,000 1057 1.97
C++ g++ #3 1,964 1307 2.62
C++ g++ #4 1,016 1287 3.36
Java #4 36,800 1524 3.41
Java #6 42,416 2543 3.52
C++ g++ #5 4,540 2344 3.75
C++ g++ #6 4,564 2324 3.89
Java #5 42,532 2473 4.14
Java #2 36,812 1257 4.46
C++ g++ #7   Make Error  
k-nucleotide
source mem gz cpu
C++ g++ #2 156,416 1631 5.92
C++ g++ #3 165,588 1276 14.14
C++ g++ 756,320 1446 14.54
Java 349,544 1812 16.17
Java #6 343,684 1607 25.67
Java #3 344,652 1635 25.73
Java #4 199,824 1882 37.48
Java #5 210,368 2219 43.27
reverse-complement
source mem gz cpu
C++ g++ #2 499,708 2093 0.64
C++ g++ #3 500,008 840 2.62
Java #8 665,804 2183 3.49
C++ g++ #6 1,513,136 1832 4.00
Java #6 2,024,016 752 4.15
Java #5 1,088,392 1108 4.92
Java #3 1,170,232 1722 5.09
Java #4 1,881,900 651 5.41
C++ g++ 979,988 592 6.34
Java #7 1,030,892 1647 23.16
C++ g++ #5 765,148 720 34.88
binary-trees
source mem gz cpu
C++ g++ #7 168,192 890 3.38
C++ g++ #5 200,020 885 4.10
C++ g++ #9 135,652 809 4.16
C++ g++ #3 265,220 945 4.65
C++ g++ #6 265,784 844 4.72
C++ g++ #8 265,808 820 5.05
Java #3 2,106,820 540 5.19
Java #6 2,093,916 529 5.35
Java #4 2,079,388 840 5.44
Java #2 1,877,464 552 5.45
Java #7 2,460,388 835 7.73
C++ g++ 1,947,704 754 8.99
C++ g++ #2 265,180 508 22.61
C++ g++ #4   Make Error  
C++ g++

11.2.0-19ubuntu1

Java

openjdk 18 2022-03-22
OpenJDK Runtime Environment
(build 18+36-2087)
OpenJDK 64-Bit Server VM
(build 18+36-2087,
mixed mode, sharing)