The Computer Language
24.06 Benchmarks Game

C# .NET versus C++ g++ 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# .NET #8 2.22 31,568 1485 8.64
C++ g++ #6 3.26 19,712 1535 12.91
C++ g++ #7 13.96 19,712 1156 13.96
C# .NET #2 29.59 30,836 584 29.58
C++ g++ #5 8.00 19,712 987 31.23
C# .NET #6 8.67 30,968 1075 34.39
C# .NET #9 9.08 32,348 1232 36.00
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++ g++ 10.87 19,712 1065 42.73
C# .NET #3 11.34 31,120 1117 44.67
C# .NET #7   Bad Output  
n-body
source secs mem gz cpu secs
C++ g++ #0 2.15 19,736 1933 2.15
C# .NET #9 3.16 30,388 2480 3.16
C# .NET #4 3.75 30,516 2137 3.74
C++ g++ #7 3.96 19,736 1815 3.96
C++ g++ #2 4.20 19,736 1884 4.20
C# .NET #7 4.79 30,640 1715 4.79
C# .NET #6 4.82 30,640 1754 4.81
C++ g++ #3 5.31 19,736 1402 5.31
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# .NET #3 6.65 31,492 1311 6.64
C# .NET #2 6.83 31,524 1350 6.82
C# .NET #8 6.83 31,528 1339 6.82
C++ g++ #6 6.91 19,736 1674 6.91
C# .NET 7.80 31,508 1424 7.79
spectral-norm
source secs mem gz cpu secs
C++ g++ #6 0.72 19,884 1050 2.85
C# .NET #5 0.93 36,476 776 3.41
C++ g++ #5 1.33 19,788 1050 5.27
C++ g++ 5.37 19,852 459 5.37
C# .NET 5.40 31,616 480 5.39
C# .NET #2 1.52 31,884 1084 5.76
C# .NET #3 1.54 33,792 890 5.86
C++ g++ #8 1.52 19,820 1284 6.06
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++ g++ #0 2.36 35,456 2752 9.30
C# .NET #9 3.25 66,864 822 12.60
C# .NET 3.23 66,980 1980 12.62
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++ g++ #7 3.51 35,072 1023 13.94
C# .NET #5 4.04 66,356 851 15.80
C++ g++ #2 16.94 34,560 700 16.94
C# .NET #3 6.82 64,780 722 26.83
C++ g++ #3 27.27 19,736 421 27.27
C# .NET #2 45.64 31,992 504 45.64
pidigits
source secs mem gz cpu secs
C++ g++ #5 0.87 19,736 804 0.87
C++ g++ #4 0.89 19,736 521 0.88
C# .NET #6 0.96 33,240 1182 0.95
C# .NET #5 0.93 35,096 990 0.96
C# .NET #4 1.36 33,952 1135 1.35
C# .NET #7 6.59 53,412 579 7.20
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.18 276,148 2856 2.23
C# .NET #8 1.43 389,120 1881 2.67
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# .NET 4.60 847,380 641 4.84
C# .NET #5 2.11 860,544 679 6.32
C++ g++ #3 12.46 215,472 859 18.08
C# .NET #4 13.15 960,820 854 44.64
C++ g++ #4   Make Error  
fasta
source secs mem gz cpu secs
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++ g++ #4 3.34 19,712 1291 3.34
C++ g++ #5 1.07 19,712 2345 3.67
C++ g++ #6 1.07 19,712 2326 3.85
C# .NET #5 1.50 62,072 1702 5.46
C# .NET 1.84 52,300 2113 6.73
C++ g++ #7   Make Error  
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.02 156,512 1634 6.09
C# .NET 3.04 184,820 2046 10.53
C# .NET #6 5.06 187,908 1615 12.77
C++ g++ #3 4.18 165,384 1280 13.93
C++ g++ 7.10 757,084 1452 14.78
C# .NET #7 40.69 762,328 1449 41.14
C# .NET #4 11.67 778,008 1725 41.58
reverse-complement
source secs mem gz cpu secs
C++ g++ #2 0.71 499,712 2099 0.71
C# .NET #8 0.56 736,084 2641 1.35
C# .NET 2.97 798,004 1130 3.15
C# .NET #5 2.64 1,026,620 1620 3.67
C# .NET #6 1.64 1,027,256 1627 3.95
C# .NET #7 1.56 941,012 1312 4.23
C++ g++ #6 3.26 1,517,580 1827 4.32
C++ g++ 6.50 979,912 599 6.50
C# .NET #3 7.31 1,571,904 934 11.48
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++ g++ #9 1.65 136,064 815 4.55
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# .NET #7 4.61 1,552,024 706 15.20
C# .NET #2 4.73 1,619,108 717 15.24
C# .NET #3 5.08 1,955,472 688 16.49
C# .NET 5.23 2,107,524 668 16.88
C++ g++ #2 21.96 265,856 514 21.96
C++ g++ #4   Make Error  
C# .NET

.NET SDK 8.0.301
Host Version: 8.0.6
Commit: 3b8b000a0e
<AllowUnsafeBlocks>true
<ServerGarbageCollection>true
<ConcurrentGarbageCollection>true
<PublishAot>false
<OptimizationPreference>Speed
<IlcInstructionSet>native

C++ g++

Ubuntu 13.2.0-23ubuntu4