The Computer Language
25.02 Benchmarks Game

C# versus Go

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
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
* C# #5 2.35 33,559 1485 7.63 9.03
C# #2 30.41 32,924 584 8.13 30.39
Go #3 8.36 3,846 975 5.31 33.35
* C# #9 8.43 34,038 1232 7.74 33.37
C# #6 9.95 33,300 1075 7.64 39.50—39.54
C# #3 11.04 33,182 1117 7.89 44.49—46.04
C# #8 43.84 32,858 519 7.51 43.83—43.87
Go #8 46.15 3,207 500 5.43 46.26—46.33
Go 12.27 4,903 906 5.41 49.09
Go #2 12.36 16,966 903 5.43 49.40
n-body
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
* C# #9 3.20 32,059 2480 7.92 3.18
* C# #4 3.77 32,215 2137 8.55 3.75
* C# #7 4.83 32,297 1715 7.54 4.81
* C# #6 4.85 32,203 1754 7.89 4.84
Go #3 6.39 3,191 1207 5.43 6.41
C# #3 6.68 33,280 1311 7.62 6.66
C# #2 6.92 33,280 1339 7.93 6.92
Go 7.02 3,228 1316 5.36 7.09—7.27
Go #2 7.04 3,203 1222 5.35 7.06
C# #8 7.24 32,870 1335 7.70 7.23
C# 7.68 33,341 1424 7.60 7.67
C# #0 7.68 33,300 1342 7.60 7.67
Go #8 9.60 3,191 1224 5.47 9.64
spectral-norm
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
* C# #5 0.96 37,929 776 8.71 3.44—3.64
Go #8 5.34 3,838 429 5.35 5.36
Go 5.34 4,059 417 5.35 5.36
C# #8 5.43 33,214 441 7.70 5.41
Go #4 1.43 4,174 555 5.45 5.69
Go #2 1.51 4,317 674 5.56 5.70
C# #3 1.56 36,172 890 8.36 5.82
C# #2   Empty  
mandelbrot
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
* C# #7 3.23 73,056 915 7.76 12.59—12.90
Go #4 3.77 37,970 912 5.49 15.02
Go #3 3.78 38,101 900 5.82 15.03
* C# 3.97 70,214 1980 10.98 15.56—15.67
* C# #9 3.95 70,402 822 7.95 15.46—15.61
C# #5 4.08 68,202 851 11.86 15.88
Go 5.04 35,787 829 5.40 20.05
C# #8 26.42 33,915 492 7.59 26.42
C# #3 6.81 66,859 722 7.65 26.76—26.83
Go #8 26.70 3,199 500 5.39 26.77
Go #2 6.87 35,549 843 5.69 27.32
Go #6 6.91 35,119 707 5.69 27.48
C# #2 47.72 33,300 504 7.60 48.00—48.46
fasta
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
C# #9 1.23 33,571 1512 7.79 1.23
Go 3.74 3,207 1055 5.36 3.76
Go #2 1.27 12,644 1405 5.51 4.08
Go #3 1.52 5,095 1362 5.29 4.10
C# #5 1.53 47,833 1702 7.79 5.45—5.54
C# #8 5.80 37,343 904 8.59 5.49
C# 1.80 40,841 2113 7.88 6.22—6.38
Go #8 11.22 9,052 880 5.55 11.54—11.80
k-nucleotide
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
C# 3.26 190,829 2046 7.66 10.80—11.05
C# #6 5.73 189,972 1615 7.65 15.07—15.28
Go #7 7.58 168,186 1613 5.42 28.83—29.08
Go #3 8.20 150,413 1729 5.63 29.98—30.69
Go #6 8.30 150,442 1596 5.79 30.22—30.75
Go #4 9.27 144,650 1552 5.11 32.00—35.21
C# #4 12.25 606,466 1725 7.64 43.35—45.07
C# #7 42.96 557,740 1449 7.50 43.57—43.83
Go #8 61.38 558,379 752 5.20 62.37—62.83
C# #8 87.51 1,408,664 736 7.89 79.54—80.86
reverse-complement
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
C# #9 0.68 550,793 2641 12.35 1.51
Go #2 2.22 822,211 614 4.79 2.34—2.39
Go #3 2.50 821,985 609 4.88 2.62—2.66
C# 3.32 666,341 1130 7.59 3.31—3.39
Go #6 1.93 1,277,608 1340 4.77 3.46—3.52
C# #5 2.59 1,056,952 1620 7.47 3.87
C# #6 1.75 1,058,517 1627 7.69 4.03—4.07
C# #7 1.69 967,602 1312 11.98 4.47—4.62
C# #3 8.65 1,266,110 934 8.01 13.47—13.71
Go #5   Bad Output  
Go   Empty  
binary-trees
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
C# #8 16.51 859,582 601 10.54 16.72—16.91
C# #2 6.47 1,107,055 717 7.59 18.08—18.35
C# #7 6.40 1,053,831 706 7.48 18.01—18.41
C# 7.20 3,005,301 668 8.11 20.10—20.51
C# #3 7.42 3,014,975 688 7.55 20.59—21.11
Go #6 27.93 416,195 618 5.43 29.32—29.66
Go #2 14.21 635,613 672 5.41 56.45—56.55
Go #3 14.90 329,499 806 5.29 57.97—58.17
Go #5 14.68 386,056 957 5.41 57.76—58.07
Go 32.05 243,114 488 5.21 59.81—60.00
Go #7 32.57 241,345 531 5.30 61.40—61.53
C# #6   Empty  
pidigits
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
* C# #6 0.84 34,796 1182 7.91 0.82
* Go #4 0.82 6,402 689 8.17 0.84
* C# #5 0.86 37,335 990 7.47 0.89
Go 1.15 7,533 715 11.71 1.22—1.31
* Go #3 1.17 6,885 610 8.50 1.35—1.49
* C# #4 1.31 35,496 1135 7.69 1.30
Go #2 1.76 7,823 740 7.70 1.90—2.03
Go #6 2.47 10,703 727 5.59 2.48
Go #7 5.00 10,527 702 6.17 5.65
C# #7 11.08 44,098 579 7.80 9.19—10.76
regex-redux
  elapsed       Mean or 95% CI
source secs mem gz make cpu secs
C# #2 1.43 402,747 1881 7.54 2.64
C# 4.63 618,988 641 7.95 4.83
C# #5 1.90 632,472 679 7.53 5.18—5.38
Go #5 3.23 297,800 817 8.13 5.40—5.44
C# #4 8.59 882,033 854 7.44 30.62—33.76
Go #4 14.49 349,008 832 8.44 35.20—35.71
Go #3 25.15 336,585 836 5.60 61.72—63.46
Go 25.79 301,662 749 5.85 61.91—62.99
C#

.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

Go

go version go1.23.1 linux/amd64
GOAMD64=v2