Swift VS C# benchmarks

Current benchmark data was generated on Tue Mar 25 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 987ms 29ms 207.3MB 987ms 150ms dotnet 9.0.202
csharp 1.cs 1059ms 17ms 186.1MB 1060ms 143ms dotnet/aot 9.0.202
csharp 1.cs 1745ms 50ms 99.7MB 1947ms 213ms mono 6.12.0
swift 1.swift 2950ms 76ms 53.9MB 2917ms 20ms swift 6.0.3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 132ms 9.0ms 34.1MB 97ms 30ms dotnet/aot 9.0.202
csharp 1.cs 151ms 3.1ms 44.1MB 127ms 10ms mono 6.12.0
csharp 1.cs 202ms 3.4ms 50.0MB 160ms 37ms dotnet 9.0.202
swift 1.swift 237ms 1.1ms 11.9MB 227ms 0ms swift 6.0.3

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2483ms 17ms 5.6MB 2473ms 0ms swift 6.0.3

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 214ms 1.8ms 6.3MB 207ms 0ms swift 6.0.3

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 129ms 4.7ms 26.3MB 357ms 83ms dotnet/aot 9.0.202
swift 3-m.swift 135ms 1.1ms 20.9MB 387ms 0ms swift 6.0.3
csharp 5-m.cs 201ms 12ms 39.6MB 470ms 117ms dotnet 9.0.202
csharp 5-m.cs 235ms 14ms 38.1MB 660ms 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 1.9ms 16.5MB 33ms 20ms dotnet/aot 9.0.202
swift 3.swift 36ms 0.3ms 18.3MB 30ms 0ms swift 6.0.3
csharp 5-m.cs 62ms 1.0ms 37.3MB 87ms 20ms dotnet 9.0.202
csharp 5-m.cs 72ms 0.5ms 31.5MB 103ms 27ms 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.5ms 0.2ms 5.9MB 0ms 0ms swift 6.0.3
csharp 1.cs 8.7ms 2.7ms 9.4MB 0ms 0ms dotnet/aot 9.0.202
csharp 1.cs 32ms 0.6ms 21.6MB 20ms 0ms mono 6.12.0
csharp 1.cs 36ms 1.2ms 26.1MB 20ms 6ms dotnet 9.0.202

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 455ms 4.7ms 46.3MB 1203ms 17ms dotnet/aot 9.0.202
csharp 6-m.cs 766ms 12ms 68.1MB 2110ms 37ms dotnet 9.0.202
csharp 6-m.cs 1021ms 12ms 68.9MB 2963ms 27ms mono 6.12.0
swift 2-m.swift 1390ms 6.6ms 74.5MB 5083ms 30ms swift 6.0.3

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 95ms 5.4ms 36.4MB 153ms 17ms dotnet/aot 9.0.202
csharp 6-m.cs 180ms 2.8ms 57.0MB 273ms 30ms dotnet 9.0.202
csharp 6-m.cs 200ms 4.3ms 58.4MB 383ms 20ms mono 6.12.0
swift 2-m.swift 263ms 1.7ms 60.0MB 693ms 23ms swift 6.0.3

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 345ms 1.2ms 9.8MB 340ms 0ms swift 6.0.3
csharp 9.cs 364ms 3.9ms 27.8MB 340ms 7ms dotnet 9.0.202
csharp 8.cs 372ms 2.5ms 9.9MB 357ms 0ms dotnet/aot 9.0.202
csharp 8.cs 422ms 2.6ms 27.5MB 400ms 10ms dotnet 9.0.202
csharp 8.cs 1256ms 5.3ms 22.3MB 1240ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 40ms 0.2ms 9.8MB 30ms 0ms swift 6.0.3
csharp 8.cs 47ms 0.7ms 9.8MB 30ms 0ms dotnet/aot 9.0.202
csharp 8.cs 96ms 1.3ms 27.5MB 80ms 10ms dotnet 9.0.202
csharp 9.cs 97ms 4.6ms 27.8MB 73ms 10ms dotnet 9.0.202
csharp 8.cs 165ms 1.2ms 20.8MB 150ms 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 3274ms 18ms 13.9MB 3170ms 103ms dotnet/aot 9.0.202
csharp 1.cs 3581ms 55ms 38.1MB 3593ms 127ms dotnet 9.0.202
swift 1.swift timeout 0.0ms 7.1MB 4910ms 70ms swift 6.0.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 760ms 1.6ms 13.5MB 723ms 23ms dotnet/aot 9.0.202
csharp 1.cs 993ms 12ms 37.8MB 1093ms 37ms dotnet 9.0.202
swift 1.swift 1877ms 8.7ms 7.0MB 1863ms 0ms swift 6.0.3