The Computer Language
24.11 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 #5 2.27 29,584 1485 8.79
* C++ g++ #6 3.31 19,760 1535 13.11
* C++ g++ #7 14.03 19,760 1156 14.03
C# .NET #2 30.38 28,804 584 30.37
C++ g++ #5 7.85 19,760 987 30.68
* C# .NET #9 8.40 29,608 1232 33.33
C++ g++ #4 8.92 19,760 1445 35.00
C++ g++ #2 9.13 19,760 1446 35.73
C++ g++ #3 37.88 19,760 600 37.87
C# .NET #6 9.93 29,272 1075 39.49
C++ g++ 10.49 19,760 1065 41.21
C# .NET #3 11.01 29,020 1117 43.46
C# .NET #8 43.80 28,760 519 43.78
n-body
source secs mem gz cpu secs
* C++ g++ #0 2.15 19,760 1933 2.15
* C# .NET #9 3.17 28,604 2480 3.17
* C# .NET #4 3.75 28,504 2137 3.75
* C++ g++ #7 4.11 19,760 1815 4.11
* C# .NET #7 4.80 28,564 1715 4.80
* C# .NET #6 4.83 28,512 1754 4.83
C++ g++ #9 5.14 19,760 1536 5.14
C++ g++ #3 5.32 19,760 1402 5.32
* C++ g++ #4 5.45 19,760 1434 5.45
* C++ g++ #2 6.02 19,352 1524 6.01
C++ g++ #5 6.32 19,760 1544 6.32
C++ g++ 6.61 19,760 1666 6.61
C# .NET #3 6.65 29,280 1311 6.64
C# .NET #2 6.89 29,284 1339 6.89
C++ g++ #6 6.93 19,760 1674 6.93
C# .NET #8 7.21 29,068 1335 7.21
C# .NET 7.66 29,380 1424 7.66
C# .NET #0 7.66 29,360 1342 7.66
spectral-norm
source secs mem gz cpu secs
* C++ g++ #6 0.73 19,760 1050 2.86
* C# .NET #5 0.94 33,752 776 3.42
* C++ g++ #5 1.33 19,760 1050 5.28
C++ g++ 5.33 19,760 459 5.33
C# .NET #8 5.41 29,720 441 5.40
C# .NET #2 1.52 29,864 1084 5.78
C# .NET #3 1.54 31,460 890 5.80
C++ g++ #7 1.52 19,512 1284 6.04
mandelbrot
source secs mem gz cpu secs
* C++ g++ #4 0.89 35,344 3554 3.45
* C++ g++ 0.89 34,952 1797 3.47
* C++ g++ #6 0.98 35,080 1014 3.87
C++ g++ #0 2.35 35,476 2752 9.30
* C# .NET #7 3.21 66,484 915 12.50
* C++ g++ #7 4.86 35,176 749 13.28
C++ g++ #5 13.44 34,636 596 13.43
C++ g++ #9 3.52 35,120 732 13.55
* C# .NET 3.93 64,440 1980 15.41
* C# .NET #9 3.93 64,332 822 15.45
C# .NET #5 4.06 63,344 851 15.87
C++ g++ #2 16.95 34,636 700 16.94
C# .NET #8 26.41 29,820 492 26.41
C# .NET #3 6.79 61,964 722 26.79
C++ g++ #3 27.37 19,760 421 27.36
C# .NET #2 46.19 29,604 504 46.19
fasta
source secs mem gz cpu secs
C# .NET #9 1.21 29,432 1512 1.21
C++ g++ #9 0.78 19,352 2758 1.54
C++ g++ #2 1.84 19,760 1129 1.84
C++ g++ 1.92 19,760 1064 1.92
C++ g++ #3 2.63 19,760 1311 2.63
C++ g++ #7 0.87 19,760 2711 3.05
C++ g++ #4 3.32 19,760 1291 3.32
C++ g++ #5 1.06 19,760 2345 3.66
C++ g++ #6 1.07 19,760 2326 4.01
C# .NET #8 5.40 32,864 904 5.42
C# .NET #5 1.48 50,620 1702 5.45
C# .NET 1.70 36,636 2113 6.23
k-nucleotide
source secs mem gz cpu secs
C++ g++ #2 2.01 156,592 1634 5.98
C# .NET 3.18 181,724 2046 10.77
C++ g++ #3 4.19 165,580 1280 13.94
C++ g++ 6.96 757,156 1452 14.75
C# .NET #6 5.63 180,500 1615 14.88
C# .NET #4 12.06 612,408 1725 42.10
C# .NET #7 42.74 613,184 1449 43.35
C# .NET #8 75.50 1,371,044 736 76.56
reverse-complement
source secs mem gz cpu secs
* C++ g++ #2 0.74 499,916 2099 0.74
C# .NET #9 0.59 733,932 2641 1.37
C# .NET 3.14 583,252 1130 3.18
C# .NET #6 1.55 1,027,196 1627 3.76
C# .NET #5 2.53 1,025,008 1620 3.83
C# .NET #7 1.54 927,984 1312 4.25
C++ g++ #6 3.30 1,517,824 1827 4.38
C++ g++ 6.52 980,156 599 6.51
C# .NET #3 8.47 1,380,908 934 13.21
C++ g++ #5 37.59 771,632 704 37.58
C++ g++ #3   Bad Output  
binary-trees
source secs mem gz cpu secs
C++ g++ #7 0.97 201,512 896 3.40
C++ g++ #5 1.16 200,724 891 4.10
C++ g++ #9 1.74 136,120 815 4.63
C++ g++ #3 1.91 265,636 951 4.74
C++ g++ #6 1.91 266,120 851 4.77
C++ g++ #4 2.22 266,136 826 5.20
C++ g++ 2.65 2,153,044 760 9.23
C# .NET #8 13.50 883,524 601 15.31
C# .NET #7 5.34 1,074,228 706 17.42
C# .NET #2 5.37 1,083,480 717 17.60
C# .NET 6.11 3,178,448 668 19.93
C# .NET #3 6.45 2,900,008 688 20.33
C++ g++ #2 22.83 265,840 514 22.82
C# .NET #6   Make Error  
pidigits
source secs mem gz cpu secs
C++ g++ #4 0.71 19,760 521 0.71
* C++ g++ #5 0.73 19,760 804 0.73
* C# .NET #6 0.82 30,744 1182 0.82
* C# .NET #5 0.84 33,264 990 0.88
* C# .NET #4 1.29 31,392 1135 1.29
C# .NET #7 7.15 38,160 579 7.25
regex-redux
source secs mem gz cpu secs
C++ g++ #6 1.15 276,336 2856 2.24
C# .NET #2 1.36 402,516 1881 2.60
C# .NET 4.60 599,212 641 4.83
C# .NET #5 1.74 614,536 679 5.02
C++ g++ #3 12.38 215,640 859 17.95
C# .NET #4 8.65 854,996 854 29.97
C++ g++   Make Error  
C++ g++ #2   Make Error  
C++ g++ #5   Make Error  
C++ g++ #4   Make Error  
C# .NET

.NET SDK 9.0.100
Host Version: 9.0.0
Commit: 9d5a6a9aa4

<OutputType>Exe
<TargetFramework>net9.0
<ImplicitUsings>enable
<Nullable>enable
<AllowUnsafeBlocks>true
<ServerGarbageCollection>true
<ConcurrentGarbageCollection>true
<PublishAot>false

C++ g++

g++ (Ubuntu 14.2.0-4ubuntu2) 14.2.0