Swift VS C# benchmarks

Current benchmark data was generated on Sun Jun 01 2025, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][4 cores] AMD EPYC 7763 64-Core Processor (Model 1)

* -m in a file name stands for multi-threading or multi-processing

* -i in a file name stands for direct intrinsics usage. (Usage of simd intrinsics via libraries is not counted)

* -ffi in a file name stands for non-stdlib FFI usage

* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 901ms 14ms 197.1MB 893ms 147ms dotnet 9.0.300
csharp 1.cs 1061ms 140ms 164.4MB 963ms 127ms dotnet/aot 9.0.300
csharp 1.cs 1725ms 105ms 103.6MB 1900ms 227ms mono 6.12.0
swift 1.swift 2555ms 26ms 53.8MB 2523ms 20ms swift 6.1.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 141ms 1.3ms 46.1MB 120ms 10ms mono 6.12.0
csharp 1.cs 175ms 44ms 31.8MB 100ms 33ms dotnet/aot 9.0.300
csharp 1.cs 191ms 4.8ms 49.7MB 147ms 37ms dotnet 9.0.300
swift 1.swift 232ms 3.0ms 11.9MB 220ms 0ms swift 6.1.2

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2480ms 2.8ms 5.5MB 2470ms 0ms swift 6.1.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 214ms 2.6ms 5.5MB 207ms 0ms swift 6.1.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 124ms 7.2ms 23.0MB 350ms 80ms dotnet/aot 9.0.300
swift 3-m.swift 146ms 1.6ms 21.0MB 433ms 3ms swift 6.1.2
csharp 5-m.cs 190ms 9.8ms 39.9MB 463ms 120ms dotnet 9.0.300
csharp 5-m.cs 234ms 8.5ms 37.7MB 657ms 93ms mono 6.12.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 25ms 0.5ms 16.0MB 30ms 10ms dotnet/aot 9.0.300
swift 3.swift 38ms 0.4ms 14.4MB 33ms 0ms swift 6.1.2
csharp 5-m.cs 63ms 2.5ms 37.0MB 83ms 17ms dotnet 9.0.300
csharp 5-m.cs 72ms 3.0ms 29.5MB 103ms 20ms mono 6.12.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2.4ms 0.2ms 5.9MB 0ms 0ms swift 6.1.2
csharp 1.cs 7.8ms 2.1ms 9.5MB 0ms 0ms dotnet/aot 9.0.300
csharp 1.cs 30ms 0.5ms 21.7MB 18ms 2ms mono 6.12.0
csharp 1.cs 34ms 1.1ms 26.1MB 20ms 2ms dotnet 9.0.300

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 481ms 13ms 47.1MB 1307ms 20ms dotnet/aot 9.0.300
csharp 6-m.cs 714ms 22ms 68.3MB 1957ms 27ms dotnet 9.0.300
csharp 6-m.cs 1010ms 11ms 67.2MB 2927ms 23ms mono 6.12.0
swift 2-m.swift 1326ms 10ms 74.3MB 4847ms 33ms swift 6.1.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 97ms 6.0ms 35.6MB 167ms 13ms dotnet/aot 9.0.300
csharp 6-m.cs 179ms 8.7ms 56.7MB 260ms 27ms dotnet 9.0.300
csharp 6-m.cs 193ms 3.0ms 60.0MB 377ms 20ms mono 6.12.0
swift 2-m.swift 249ms 1.6ms 60.1MB 660ms 27ms swift 6.1.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 343ms 1.2ms 10.1MB 333ms 0ms swift 6.1.2
csharp 9.cs 360ms 3.8ms 27.9MB 340ms 10ms dotnet 9.0.300
csharp 8.cs 370ms 3.3ms 9.9MB 360ms 0ms dotnet/aot 9.0.300
csharp 8.cs 419ms 1.1ms 27.6MB 400ms 3ms dotnet 9.0.300
csharp 8.cs 1252ms 4.8ms 22.3MB 1237ms 0ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 39ms 1.3ms 10.3MB 30ms 0ms swift 6.1.2
csharp 8.cs 44ms 0.2ms 9.9MB 30ms 0ms dotnet/aot 9.0.300
csharp 9.cs 93ms 3.0ms 27.6MB 73ms 7ms dotnet 9.0.300
csharp 8.cs 95ms 2.3ms 27.6MB 77ms 3ms dotnet 9.0.300
csharp 8.cs 161ms 0.7ms 22.4MB 147ms 0ms mono 6.12.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 3220ms 6.8ms 14.1MB 3130ms 87ms dotnet/aot 9.0.300
csharp 1.cs 3568ms 50ms 38.1MB 3597ms 107ms dotnet 9.0.300
swift 1.swift timeout 0.0ms 7.1MB 4920ms 67ms swift 6.1.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 759ms 6.1ms 13.5MB 727ms 20ms dotnet/aot 9.0.300
csharp 1.cs 985ms 4.4ms 37.8MB 1073ms 37ms dotnet 9.0.300
swift 1.swift 1831ms 3.2ms 7.0MB 1813ms 0ms swift 6.1.2