The Computer Language
24.09 Benchmarks Game

C++ g++ versus C gcc fastest performance

How the programs are written matters! 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 seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
C gcc #6 2.17 19,684 1582 8.56
C++ g++ #6 3.26 19,712 1535 12.91
C++ g++ #7 13.96 19,712 1156 13.96
C gcc #4 14.21 19,684 1190 14.21
C gcc #5 6.98 19,684 917 27.28
C++ g++ #5 8.00 19,712 987 31.23
C++ g++ #4 9.26 19,688 1445 36.31
C++ g++ #3 36.90 19,688 600 36.90
C++ g++ #2 9.55 19,712 1446 37.53
C gcc #3 39.56 19,684 574 39.56
C gcc 42.31 19,684 514 42.31
C gcc #2 10.85 19,684 1563 42.52
C++ g++ 10.87 19,712 1065 42.73
n-body
source secs mem gz cpu secs
C gcc #9 2.10 19,704 1639 2.10
C++ g++ #0 2.15 19,736 1933 2.15
C++ g++ #7 3.96 19,736 1815 3.96
C++ g++ #2 4.20 19,736 1884 4.20
C gcc #4 4.31 19,684 1496 4.31
C gcc #6 4.97 19,684 1186 4.97
C gcc 5.18 19,684 1179 5.18
C gcc #2 5.20 19,684 1270 5.20
C gcc #3 5.24 19,684 1214 5.24
C++ g++ #3 5.31 19,736 1402 5.31
C gcc #5 5.43 19,684 1436 5.43
C++ g++ #9 5.44 19,736 1536 5.44
C++ g++ #4 5.45 19,736 1434 5.45
C++ g++ #5 6.02 19,736 1544 6.01
C++ g++ 6.50 19,736 1666 6.50
C++ g++ #8 6.54 19,736 1524 6.54
C gcc #7 6.82 19,684 1250 6.82
C++ g++ #6 6.91 19,736 1674 6.91
spectral-norm
source secs mem gz cpu secs
C gcc #6 0.39 19,724 1203 1.54
C++ g++ #6 0.72 19,884 1050 2.85
C gcc #4 0.72 19,724 1145 2.85
C gcc #7 0.72 19,724 906 2.85
C gcc #5 0.72 19,708 576 2.86
C++ g++ #5 1.33 19,788 1050 5.27
C++ g++ 5.37 19,852 459 5.37
C gcc 5.39 19,724 390 5.39
C gcc #3 1.43 19,708 470 5.70
C++ g++ #8 1.52 19,820 1284 6.06
C gcc #8   Make Error  
mandelbrot
source secs mem gz cpu secs
C++ g++ 0.89 34,944 1797 3.47
C++ g++ #4 0.89 35,328 3554 3.47
C++ g++ #6 0.98 35,072 1014 3.90
C gcc #6 1.29 33,408 1147 5.13
C gcc #5 1.63 33,536 788 6.32
C++ g++ #0 2.36 35,456 2752 9.30
C++ g++ #8 4.84 34,944 749 13.21
C++ g++ #5 13.35 34,560 596 13.35
C++ g++ #9 3.50 35,072 732 13.49
C gcc #4 3.49 33,152 805 13.88
C gcc #7 3.50 33,280 1000 13.91
C gcc 3.50 32,768 828 13.93
C++ g++ #7 3.51 35,072 1023 13.94
C gcc #3 3.53 32,768 769 14.09
C gcc #9 4.23 33,280 700 16.34
C++ g++ #2 16.94 34,560 700 16.94
C gcc #2 25.05 19,684 412 25.04
C++ g++ #3 27.27 19,736 421 27.27
pidigits
source secs mem gz cpu secs
C gcc #2 0.82 19,704 422 0.82
C++ g++ #5 0.87 19,736 804 0.87
C++ g++ #4 0.89 19,736 521 0.88
C gcc 0.89 19,704 459 0.88
regex-redux
source secs mem gz cpu secs
C gcc #5 0.81 152,392 1403 2.03
C++ g++ #6 1.18 276,148 2856 2.23
C gcc #2 3.21 103,296 1121 3.21
C gcc #4 0.95 152,248 1237 3.27
C gcc #3 1.73 103,680 1273 3.31
C++ g++ 3.56 212,180 662 3.56
C++ g++ #2 2.86 212,648 706 3.62
C++ g++ #5 3.81 215,648 859 4.53
C++ g++ #3 12.46 215,472 859 18.08
C++ g++ #4   Make Error  
fasta
source secs mem gz cpu secs
C gcc #9 0.78 19,440 1469 0.78
C gcc #5 1.24 19,684 1286 1.24
C++ g++ #8 0.78 19,712 2758 1.54
C++ g++ #2 1.80 19,712 1129 1.80
C++ g++ 1.90 19,712 1064 1.90
C++ g++ #3 2.62 19,712 1311 2.62
C gcc #6 0.94 19,684 1936 2.77
C gcc #7 2.79 19,440 1299 2.79
C gcc #4 3.03 19,684 1244 3.03
C gcc #2 0.82 19,684 2276 3.25
C++ g++ #4 3.34 19,712 1291 3.34
C++ g++ #5 1.07 19,712 2345 3.67
C gcc 3.74 19,684 1213 3.74
C++ g++ #6 1.07 19,712 2326 3.85
C gcc #8 4.56 19,440 825 4.55
C++ g++ #7   Make Error  
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.02 156,512 1634 6.09
C gcc 3.98 130,432 1512 12.93
C++ g++ #3 4.18 165,384 1280 13.93
C++ g++ 7.10 757,084 1452 14.78
reverse-complement
source secs mem gz cpu secs
C gcc #7 0.43 499,928 1899 0.59
C++ g++ #2 0.71 499,712 2099 0.71
C gcc #9 0.49 499,744 1551 0.82
C gcc #6 0.97 696,664 828 1.39
C gcc #5 1.52 994,176 654 1.52
C gcc #2 1.05 994,560 757 1.57
C gcc #4 3.68 500,480 716 3.68
C++ g++ #6 3.26 1,517,580 1827 4.32
C++ g++ 6.50 979,912 599 6.50
C++ g++ #5 36.24 771,432 704 36.24
C++ g++ #3   Bad Output  
binary-trees
source secs mem gz cpu secs
C++ g++ #7 0.96 201,536 896 3.35
C++ g++ #5 1.15 200,660 891 4.08
C gcc #2 1.57 169,216 816 4.48
C++ g++ #9 1.65 136,064 815 4.55
C gcc #3 1.92 134,400 842 4.70
C++ g++ #6 1.92 266,112 851 4.74
C++ g++ #3 2.25 265,600 951 5.11
C++ g++ #8 2.22 266,112 826 5.26
C++ g++ 2.68 2,068,612 760 9.34
C gcc 21.32 264,064 660 21.32
C++ g++ #2 21.96 265,856 514 21.96
C gcc #5 8.66 351,232 914 31.56
C++ g++ #4   Make Error  
C++ g++

Ubuntu 13.2.0-23ubuntu4

C gcc

13.2.0-23ubuntu4