Swift VS C# benchmarks

Current benchmark data was generated on Sat Nov 16 2024, 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 942ms 23ms 178.5MB 930ms 140ms dotnet/aot 9.0.100
csharp 1.cs 1121ms 32ms 206.4MB 1067ms 147ms dotnet 9.0.100
csharp 1.cs 1708ms 66ms 101.6MB 1907ms 207ms mono 6.12.0
swift 1.swift 2516ms 49ms 56.6MB 2483ms 17ms swift 6.0.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 122ms 3.4ms 41.6MB 83ms 27ms dotnet/aot 9.0.100
csharp 1.cs 143ms 1.2ms 46.1MB 117ms 17ms mono 6.12.0
csharp 1.cs 196ms 4.9ms 59.9MB 153ms 33ms dotnet 9.0.100
swift 1.swift 230ms 2.0ms 14.8MB 220ms 0ms swift 6.0.2

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2465ms 1.7ms 8.3MB 2450ms 0ms swift 6.0.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 213ms 0.4ms 8.1MB 200ms 0ms swift 6.0.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 137ms 6.7ms 44.9MB 370ms 110ms dotnet/aot 9.0.100
swift 3-m.swift 143ms 2.7ms 27.3MB 397ms 7ms swift 6.0.2
csharp 5-m.cs 193ms 4.9ms 51.1MB 457ms 133ms dotnet 9.0.100
csharp 5-m.cs 248ms 3.8ms 55.4MB 683ms 97ms mono 6.12.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 27ms 0.5ms 24.8MB 37ms 13ms dotnet/aot 9.0.100
swift 3.swift 37ms 0.6ms 21.1MB 33ms 0ms swift 6.0.2
csharp 5-m.cs 61ms 1.8ms 44.5MB 77ms 20ms dotnet 9.0.100
csharp 5-m.cs 70ms 1.9ms 44.3MB 100ms 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 3.1ms 0.4ms 7.8MB 0ms 0ms swift 6.0.2
csharp 1.cs 9.1ms 5.6ms 15.6MB 0ms 0ms dotnet/aot 9.0.100
csharp 1.cs 31ms 0.9ms 23.4MB 20ms 0ms mono 6.12.0
csharp 1.cs 35ms 0.6ms 32.3MB 20ms 6ms dotnet 9.0.100

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 452ms 5.9ms 54.4MB 1193ms 23ms dotnet/aot 9.0.100
csharp 6-m.cs 695ms 42ms 78.3MB 1920ms 33ms dotnet 9.0.100
csharp 6-m.cs 1020ms 12ms 69.1MB 2967ms 30ms mono 6.12.0
swift 2-m.swift 1384ms 11ms 72.9MB 5030ms 33ms swift 6.0.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 85ms 4.5ms 45.0MB 153ms 10ms dotnet/aot 9.0.100
csharp 6-m.cs 169ms 7.9ms 66.9MB 240ms 37ms dotnet 9.0.100
csharp 6-m.cs 193ms 4.6ms 56.0MB 360ms 30ms mono 6.12.0
swift 2-m.swift 261ms 1.2ms 64.3MB 680ms 33ms swift 6.0.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 342ms 0.8ms 9.9MB 330ms 0ms swift 6.0.2
csharp 9.cs 358ms 1.2ms 34.0MB 347ms 0ms dotnet 9.0.100
csharp 8.cs 371ms 1.4ms 15.8MB 360ms 0ms dotnet/aot 9.0.100
csharp 8.cs 424ms 8.4ms 33.8MB 397ms 10ms dotnet 9.0.100
csharp 8.cs 1247ms 5.7ms 24.3MB 1230ms 7ms 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.7ms 10.1MB 30ms 0ms swift 6.0.2
csharp 8.cs 45ms 1.6ms 15.8MB 30ms 0ms dotnet/aot 9.0.100
csharp 9.cs 93ms 1.7ms 33.7MB 77ms 7ms dotnet 9.0.100
csharp 8.cs 94ms 0.7ms 33.7MB 73ms 10ms dotnet 9.0.100
csharp 8.cs 165ms 1.7ms 24.4MB 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 3199ms 6.2ms 19.7MB 3087ms 107ms dotnet/aot 9.0.100
csharp 1.cs 3600ms 78ms 44.2MB 3597ms 130ms dotnet 9.0.100
swift 1.swift timeout 0.0ms 10.0MB 4930ms 57ms swift 6.0.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 751ms 1.3ms 19.6MB 710ms 30ms dotnet/aot 9.0.100
csharp 1.cs 991ms 26ms 44.0MB 1090ms 37ms dotnet 9.0.100
swift 1.swift 1914ms 8.6ms 9.9MB 1897ms 3ms swift 6.0.2