The Computer Language
25.03 Benchmarks Game

Swift versus C# naot

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# naot #5 2.16 8.58 6,713 1485 24.43
C# naot #2 31.30 31.29 6,001 584 23.80
* C# naot #9 8.11 32.35 6,377 1232 25.65
* Swift #3 8.20 32.45—32.61 13,722 1103 12.93
Swift #8 34.68 34.68—34.74 13,484 470 12.33
C# naot #6 10.14 40.45—40.53 6,799 1075 24.13
C# naot #3 11.01 43.53—43.61 6,472 1117 23.77
C# naot #8 44.63 44.63 6,091 519 24.31
n-body      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# naot #9 3.13 3.12 6,087 2480 24.34
* C# naot #4 3.70 3.70 6,078 2137 24.03
* C# naot #7 4.74 4.74 6,091 1715 23.78
* C# naot #6 4.77 3.92—6.97 6,115 1754 23.74
* Swift #3 5.45 5.44—5.48 24,928 1688 14.75
* Swift #4 5.48 5.49 24,846 1361 13.94
* Swift #5 5.52 5.50—5.55 24,928 1372 12.83
* Swift #7 5.53 5.52 24,932 1333 13.80
Swift #6 5.82 5.81 12,956 1213 12.42
Swift #8 6.66 6.56—6.95 12,804 1285 12.85
C# naot #3 6.67 6.65—6.70 6,095 1311 23.76
C# naot #2 6.81 6.81 5,898 1339 24.15
C# naot #8 7.02 7.01 5,833 1335 23.65
C# naot #0 7.46 7.46 6,107 1342 23.74
C# naot 7.46 7.45 6,124 1424 24.21
Swift 7.89 7.88 12,812 1210 12.10
Swift #9 287.37 287.38—288.05 24,793 1532 13.91
spectral-norm      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# naot #5 0.74 2.88 8,057 776 24.00
C# naot #8 5.35 5.34 6,820 441 24.29
Swift #8 5.36 5.35 24,859 411 14.09
Swift #3 1.45 5.71 13,689 607 12.54
C# naot #2 1.47 5.72 6,644 1084 24.38
C# naot #3 1.48 5.80 6,808 890 23.72
mandelbrot      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Swift #7 1.35 5.29 57,836 1147 14.15
* Swift #6 1.48 5.80 60,985 1147 14.36
* C# naot #7 2.96 11.74 39,088 915 24.73
* C# naot #9 3.77 14.95 38,797 822 27.91
* C# naot 3.76 14.95 39,240 1980 24.86
C# naot #5 4.02 15.90 40,743 851 27.06
C# naot #8 25.58 25.55—25.66 6,115 492 24.73
Swift #8 25.62 25.60—25.64 12,784 426 11.26
C# naot #3 6.69 26.53 39,715 722 24.95
Swift 26.55 26.54 12,780 400 12.99
Swift #5 7.27 27.13 49,312 665 13.83
C# naot #2 47.60 47.84—48.30 6,148 504 24.02
* Swift #3   Bad Output  
fasta      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# naot #9 1.16 1.16 6,218 1512 24.53
C# naot #5 1.14 4.34—4.48 34,853 1702 24.14
* Swift 5.37 5.38 12,546 1533 13.34
* Swift #3 2.20 5.37 39,002 2097 14.73
* Swift #2 3.15 5.63—5.96 13,726 1952 14.91
C# naot 1.61 5.65—5.71 11,055 2113 24.61
C# naot #8 6.60 6.30 8,823 904 23.99
Swift #8 18.19 18.18—18.35 12,829 828 11.99
k-nucleotide      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# naot 3.12 10.70—10.91 160,424 2046 27.36
C# naot #6 5.02 13.07—13.88 158,015 1615 26.90
C# naot #4 13.01 45.70—45.82 523,211 1725 27.45
C# naot #7 48.00 48.44—48.60 593,142 1449 23.68
* Swift #2 14.45 54.24—57.70 273,949 1373 15.39
C# naot #8 83.91 75.78—77.28 1,354,269 736 24.68
Swift #8 166.95 168.68—173.38 650,023 658 14.46
Swift #7 223.40 226.91—248.09 650,023 607 13.04
Swift   Empty  
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Swift 2.05 2.48 825,635 1293 14.28
C# naot 3.37 3.40—3.44 637,997 1130 24.13
C# naot #5 2.74 3.76 1,027,035 1620 24.63
C# naot #7 1.56 4.14—4.23 774,136 1312 23.76
C# naot #6 1.81 4.27—4.31 1,029,992 1627 24.50
C# naot #3 8.76 13.32—13.49 1,236,947 934 23.97
* C# naot #9   Bad Output  
binary-trees      [ Contentious. Different approaches. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
C# naot #7 6.22 17.09—17.67 1,115,476 706 23.97
C# naot #2 6.22 17.12—17.72 1,018,946 717 23.74
C# naot #3 6.71 18.09—18.62 2,829,128 688 23.94
C# naot 6.80 18.92—19.25 2,819,092 668 24.30
Swift 18.21 54.03—54.29 763,523 720 13.97
Swift #4 17.62 54.69—59.64 733,094 772 13.31
Swift #5 18.90 56.44—56.88 764,391 813 14.89
Swift #3 18.26 58.41—58.87 733,180 868 18.46
Swift #2 18.24 58.41—58.84 732,828 822 14.89
C# naot #6   Empty  
* Swift #9   Empty  
pidigits      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# naot #6 0.75 0.75 7,905 1182 23.89
* Swift #2 0.76 0.75 14,459 606 12.50
* C# naot #4 4.54 4.53 8,053 1135 28.23
C# naot #7 11.42 8.23—9.42 11,723 579 24.08
* C# naot #5 99.09 99.08—99.12 8,466 990 24.29
regex-redux      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* C# naot #2 1.36 2.55 320,512 1881 25.36
C# naot 10.69 10.70—10.79 582,550 641 27.07
C# naot #5 3.25 10.73—10.77 596,599 679 26.47
C# naot #4 9.81 32.95—33.06 743,510 854 26.94
Swift #2 39.33 39.34—39.45 710,697 678 13.66
Swift 23.92 40.23—40.37 922,243 721 13.56
Swift #4 18.21 41.75—42.40 1,102,254 751 13.30
Swift

Swift version 6.0.3
(swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu

C# naot

.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>true
<OptimizationPreference>Speed
<IlcInstructionSet>native