The Computer Language
25.02 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.22 32.50—32.61 13,808 1103 14.41
Swift #8 34.68 34.68—34.78 13,476 470 12.23
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.46 5.45—5.53 25,002 1688 14.30
* Swift #4 5.49 5.49 25,010 1361 15.19
* Swift #5 5.52 5.50—5.55 25,010 1372 15.67
* Swift #7 5.53 5.52 25,010 1333 14.58
Swift #6 5.81 5.79—5.86 12,947 1213 13.99
Swift #8 6.66 6.66 12,808 1285 12.73
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,808 1210 13.77
Swift #9 287.49 287.49—288.02 24,867 1532 14.21
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,936 411 15.00
Swift #3 1.45 5.71 13,705 607 13.91
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.30 57,856 1147 15.57
* Swift #6 1.48 5.78 60,969 1147 15.74
* 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.63 25.62 12,841 426 13.44
C# naot #3 6.69 26.53 39,715 722 24.95
Swift 26.55 26.54 12,853 400 13.78
Swift #5 7.28 27.12 49,291 665 14.09
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
* Swift #2 2.24 4.74—5.94 13,767 1952 15.21
C# naot #5 1.14 4.34—4.48 34,853 1702 24.14
* Swift #3 2.20 5.37 39,313 2097 16.81
* Swift 5.43 5.42—5.47 12,640 1533 14.40
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.86 18.86—18.92 12,837 828 13.46
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.46 55.16—55.44 273,932 1373 14.99
C# naot #8 83.91 75.78—77.28 1,354,269 736 24.68
Swift #8 167.99 175.66—188.61 904,810 658 14.96
Swift #7 225.53 231.92—242.63 649,970 607 14.99
Swift   Empty  
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Swift 1.97 2.41 825,594 1293 16.00
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.32 54.27—54.38 763,609 720 15.54
Swift #4 17.69 55.61—57.68 733,131 772 15.64
Swift #5 18.99 56.13—58.05 764,781 813 14.50
Swift #2 18.36 58.30—64.86 733,131 822 15.77
Swift #3 18.24 58.63—59.13 733,000 868 14.57
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,238 606 13.58
* 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 38.81 38.84—39.05 710,750 678 14.74
Swift 23.39 39.78—39.91 922,284 721 13.23
Swift #4 18.22 41.22—41.58 1,099,583 751 14.65
Swift

Swift version 6.0
(swift-6.0-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