The Computer Language
25.02 Benchmarks Game

C# versus F#

How the programs are written matters! Always look at the source code.

If the fastest programs are flagged * possible hand-written vector instructions or "unsafe" or naked ffi, 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 cpu secs mem gz make
* C# #5 2.35 9.03 33,559 1485 7.63
C# #2 30.41 30.39 32,924 584 8.13
F# #6 8.37 32.48 41,243 1103 13.16
* C# #9 8.43 33.37 34,038 1232 7.74
F# #5 9.75 38.47—38.98 46,322 927 12.19
C# #6 9.95 39.50—39.54 33,300 1075 7.64
C# #3 11.04 44.49—46.04 33,182 1117 7.89
C# #8 43.84 43.83—43.87 32,858 519 7.51
F# 149.70 111.07—115.04 46,936 558 12.12
n-body      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# #9 3.20 3.18 32,059 2480 7.92
* C# #4 3.77 3.75 32,215 2137 8.55
* C# #7 4.83 4.81 32,297 1715 7.54
* C# #6 4.85 4.84 32,203 1754 7.89
* F# #6 5.01 5.00 43,221 1395 17.01
* F# #5 5.85 5.86 43,524 1363 15.40
C# #3 6.68 6.66 33,280 1311 7.62
C# #2 6.92 6.92 33,280 1339 7.93
F# #4 6.95 6.93 43,553 1296 12.46
F# #3 6.99 6.97 41,685 1624 13.55
C# #8 7.24 7.23 32,870 1335 7.70
F# #2 7.36 7.35 43,639 1387 12.75
C# 7.68 7.67 33,341 1424 7.60
C# #0 7.68 7.67 33,300 1342 7.60
F# 8.77 8.03—8.08 46,506 1272 12.23
spectral-norm      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* F# #6 0.95 3.33—3.44 47,010 697 15.15
* C# #5 0.96 3.44—3.64 37,929 776 8.71
C# #8 5.43 5.41 33,214 441 7.70
C# #3 1.56 5.82 36,172 890 8.36
F# #2 1.59 2.41—6.07 44,683 864 12.01
F# #4 1.60 5.86 46,375 738 11.38
C# #2   Empty  
mandelbrot      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# #7 3.23 12.59—12.90 73,056 915 7.76
* C# 3.97 15.56—15.67 70,214 1980 10.98
* C# #9 3.95 15.46—15.61 70,402 822 7.95
C# #5 4.08 15.88 68,202 851 11.86
* F# #6 4.18 16.28—16.45 77,173 943 14.24
* F# 4.42 17.24—17.42 77,042 890 14.07
C# #8 26.42 26.42 33,915 492 7.59
C# #3 6.81 26.76—26.83 66,859 722 7.65
F# #2 7.17 28.10—28.29 49,979 1054 12.10
C# #2 47.72 48.00—48.46 33,300 504 7.60
fasta      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# #9 1.23 1.23 33,571 1512 7.79
F# #3 1.16 4.07 58,302 1361 12.17
C# #5 1.53 5.45—5.54 47,833 1702 7.79
F# #4 1.48 5.50—5.61 66,576 1355 12.35
C# #8 5.80 5.49 37,343 904 8.59
C# 1.80 6.22—6.38 40,841 2113 7.88
k-nucleotide      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# 3.26 10.80—11.05 190,829 2046 7.66
F# #6 3.77 11.89—12.02 200,847 1913 12.63
C# #6 5.73 15.07—15.28 189,972 1615 7.65
F# #5 4.74 16.10—16.34 213,168 1964 12.97
F# #2 4.75 16.17—16.28 212,804 1932 12.62
F# #3 13.00 28.91—29.45 1,357,251 1124 12.67
F# #4 11.38 29.66—30.72 1,356,919 1522 12.66
C# #4 12.25 43.35—45.07 606,466 1725 7.64
C# #7 42.96 43.57—43.83 557,740 1449 7.50
C# #8 87.51 79.54—80.86 1,408,664 736 7.89
F# 39.58 92.39—94.04 932,966 713 12.15
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# #9 0.68 1.51 550,793 2641 12.35
C# 3.32 3.31—3.39 666,341 1130 7.59
C# #5 2.59 3.87 1,056,952 1620 7.47
C# #6 1.75 4.03—4.07 1,058,517 1627 7.69
C# #7 1.69 4.47—4.62 967,602 1312 11.98
C# #3 8.65 13.47—13.71 1,266,110 934 8.01
F# 41.59 43.03—43.44 3,088,159 603 12.36
F# #4   Timed Out  
F# #5   Timed Out  
binary-trees      [ Contentious. Different approaches. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
F# 14.36 15.26—15.61 938,693 517 13.10
C# #2 6.47 18.08—18.35 1,107,055 717 7.59
C# #7 6.40 18.01—18.41 1,053,831 706 7.48
C# 7.20 20.10—20.51 3,005,301 668 8.11
C# #3 7.42 20.59—21.11 3,014,975 688 7.55
F# #7 8.98 23.05—23.86 1,127,907 527 12.31
C# #6   Empty  
pidigits      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# #6 0.84 0.82 34,796 1182 7.91
* F# #6 0.84 0.83 40,571 917 12.37
* C# #5 0.86 0.89 37,335 990 7.47
* C# #4 1.31 1.30 35,496 1135 7.69
* F# #4 1.32 1.34 41,902 887 13.65
C# #7 11.08 9.19—10.76 44,098 579 7.80
regex-redux      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# #2 1.43 2.64 402,747 1881 7.54
C# 4.63 4.83 618,988 641 7.95
F# #2 4.81 5.03 879,477 437 11.89
F# #6 1.81 5.23—5.44 787,112 622 12.16
C# #5 1.90 5.18—5.38 632,472 679 7.53
F# #7 5.59 6.65—6.73 686,174 610 12.14
C# #4 8.59 30.62—33.76 882,033 854 7.44
F#   Bad Output  
F# #4   Bad Output  
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

F#

.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