The Computer Language
24.11 Benchmarks Game

Swift versus C# aot 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# aot #5 2.16 19,620 1485 8.57
C# aot #2 31.28 19,620 584 31.27
C# aot #9 8.10 19,620 1232 32.31
* Swift #3 8.32 19,440 1103 32.99
Swift #8 35.13 19,444 470 35.12
C# aot #6 10.11 19,620 1075 40.42
C# aot #3 11.00 19,620 1117 43.50
C# aot #8 44.61 19,620 519 44.60
n-body
source secs mem gz cpu secs
C# aot #9 3.11 19,620 2480 3.11
C# aot #4 3.69 19,620 2137 3.69
C# aot #7 4.73 19,620 1715 4.73
C# aot #6 4.75 19,620 1754 4.75
* Swift #3 5.43 19,440 1688 5.43
* Swift #4 5.46 19,440 1361 5.46
* Swift #5 5.49 19,440 1372 5.49
* Swift #7 5.50 19,440 1333 5.50
Swift #6 5.78 19,440 1213 5.78
C# aot #0 6.39 19,620 1342 6.39
C# aot 6.39 19,620 1424 6.39
Swift #8 6.65 19,440 1285 6.65
C# aot #3 6.65 19,620 1311 6.65
C# aot #2 6.80 19,620 1339 6.80
C# aot #8 7.00 19,620 1335 7.00
Swift 7.85 19,440 1210 7.85
Swift #9 288.23 19,440 1532 288.20
spectral-norm
source secs mem gz cpu secs
C# aot #5 0.73 19,620 776 2.87
Swift #8 5.33 19,568 411 5.33
C# aot #8 5.33 19,620 441 5.33
Swift #3 1.43 19,440 607 5.69
C# aot #2 1.47 19,620 1084 5.71
C# aot #3 1.47 19,620 890 5.79
mandelbrot
source secs mem gz cpu secs
* Swift #7 1.38 49,024 1147 5.49
* Swift #6 1.46 51,840 1147 5.78
C# aot #7 2.95 36,040 915 11.72
C# aot 3.75 36,080 1980 14.93
C# aot #9 3.76 36,024 822 14.94
C# aot #5 4.00 37,728 851 15.87
C# aot #8 25.56 19,620 492 25.55
Swift #8 25.59 19,492 426 25.59
Swift 26.45 19,440 400 26.45
C# aot #3 6.67 36,584 722 26.51
Swift #5 7.25 43,648 665 27.03
C# aot #2 46.14 19,620 504 46.12
* Swift #3   Bad Output  
fasta
source secs mem gz cpu secs
C# aot #9 1.15 19,620 1512 1.15
* Swift #2 2.11 19,440 1952 3.76
C# aot #5 1.08 45,836 1702 4.23
* Swift 5.15 19,440 1533 5.14
* Swift #3 2.18 31,248 2097 5.40
C# aot 1.60 19,620 2113 5.69
C# aot #8 6.23 19,964 904 6.22
Swift #8 18.86 19,972 828 18.86
k-nucleotide
source secs mem gz cpu secs
C# aot 3.08 153,728 2046 10.56
C# aot #6 5.08 152,196 1615 12.83
C# aot #4 12.88 577,808 1725 45.69
C# aot #7 47.60 571,928 1449 48.16
* Swift #2 14.54 260,820 1373 55.20
C# aot #8 72.83 1,322,384 736 73.39
Swift #8 181.50 627,328 658 180.87
Swift #7 233.16 627,092 607 232.52
Swift   Make Error  
reverse-complement
source secs mem gz cpu secs
* Swift 1.95 798,228 1293 2.39
C# aot 3.23 548,304 1130 3.25
C# aot #5 2.71 998,644 1620 3.73
C# aot #7 1.43 816,640 1312 3.92
C# aot #6 1.71 1,001,884 1627 4.12
C# aot #3 8.66 1,368,572 934 13.17
C# aot #9   Bad Output  
binary-trees
source secs mem gz cpu secs
C# aot #8 14.53 835,476 601 16.02
C# aot #2 5.04 1,203,112 717 16.32
C# aot #7 5.32 1,167,436 706 17.19
C# aot #3 5.85 2,944,336 688 17.86
C# aot 5.69 2,875,588 668 18.10
Swift 18.28 737,152 720 54.20
Swift #8 54.90 402,048 567 54.89
Swift #4 17.49 707,456 772 55.84
Swift #5 18.89 738,048 813 56.25
Swift #2 18.29 707,456 822 58.16
Swift #3 18.18 707,584 868 58.24
C# aot #6   Make Error  
* Swift #9   Make Error  
pidigits
source secs mem gz cpu secs
C# aot #6 0.74 19,620 1182 0.74
* Swift #2 0.75 19,440 606 0.75
C# aot #4 4.53 19,620 1135 4.53
C# aot #7 6.43 19,620 579 6.39
C# aot #5 99.21 19,620 990 99.18
regex-redux
source secs mem gz cpu secs
C# aot #2 1.30 327,112 1881 2.50
C# aot 10.61 566,272 641 10.61
C# aot #5 3.20 579,456 679 10.70
C# aot #4 9.74 729,588 854 33.09
Swift #2 38.80 686,136 678 38.80
Swift 23.40 891,792 721 39.65
Swift #4 18.30 1,064,768 751 41.36
Swift

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

C# aot

.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