Swift VS C# benchmarks

Current benchmark data was generated on Thu Jul 13 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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 1238ms 15ms 384.0MB 1173ms 167ms dotnet/aot 7.0.306
csharp 1.cs 1474ms 24ms 397.6MB 1343ms 190ms dotnet 7.0.306
csharp 1.cs 2201ms 41ms 104.3MB 2517ms 157ms mono 6.12.0
swift 1.swift 2559ms 11ms 52.7MB 2533ms 10ms swift 5.8.1

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 126ms 4.3ms 72.0MB 100ms 23ms dotnet/aot 7.0.306
csharp 1.cs 153ms 0.8ms 44.0MB 137ms 3ms mono 6.12.0
swift 1.swift 237ms 3.5ms 10.4MB 223ms 0ms swift 5.8.1
csharp 1.cs 237ms 4.4ms 95.5MB 180ms 33ms dotnet 7.0.306

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3306ms 8.5ms 2.3MB 3290ms 0ms swift 5.8.1

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 280ms 1.5ms 2.3MB 270ms 0ms swift 5.8.1

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 310ms 4.4ms 21.0MB 543ms 3ms swift 5.8.1
csharp 5-m.cs 366ms 49ms 57.8MB 560ms 127ms dotnet/aot 7.0.306
csharp 5-m.cs 482ms 25ms 68.6MB 743ms 127ms dotnet 7.0.306
csharp 5-m.cs 482ms 6.9ms 38.3MB 823ms 80ms mono 6.12.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 55ms 0.7ms 14.4MB 53ms 0ms swift 5.8.1
csharp 5-m.cs 60ms 1.7ms 28.3MB 77ms 17ms dotnet/aot 7.0.306
csharp 5-m.cs 97ms 6.4ms 38.3MB 113ms 37ms mono 6.12.0
csharp 5.cs 108ms 2.9ms 39.9MB 93ms 20ms dotnet 7.0.306

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2.0ms 0.6ms 4.7MB 0ms 0ms swift 5.8.1
csharp 1.cs 6.8ms 0.8ms 12.1MB 0ms 0ms dotnet/aot 7.0.306
csharp 1.cs 19ms 0.6ms 25.6MB 10ms 0ms mono 6.12.0
csharp 1.cs 59ms 1.9ms 28.8MB 26ms 2ms dotnet 7.0.306

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 971ms 8.0ms 51.8MB 1473ms 27ms dotnet/aot 7.0.306
csharp 6-m.cs 1667ms 172ms 68.9MB 2523ms 20ms mono 6.12.0
swift 2-m.swift 2297ms 447ms 52.2MB 3860ms 20ms swift 5.8.1
csharp 6-m.cs 3820ms 672ms 73.4MB 7300ms 23ms dotnet 7.0.306

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6.cs 152ms 4.0ms 42.6MB 177ms 23ms dotnet/aot 7.0.306
csharp 6.cs 233ms 3.9ms 51.1MB 310ms 10ms mono 6.12.0
swift 2-m.swift 357ms 7.2ms 31.5MB 603ms 13ms swift 5.8.1
csharp 6-m.cs 501ms 70ms 61.9MB 793ms 23ms dotnet 7.0.306

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 9.cs 407ms 0.4ms 29.8MB 380ms 0ms dotnet 7.0.306
swift 7.swift 433ms 0.3ms 5.3MB 420ms 0ms swift 5.8.1
csharp 8.cs 498ms 4.0ms 10.1MB 497ms 0ms dotnet/aot 7.0.306
csharp 8.cs 538ms 1.3ms 25.7MB 503ms 0ms dotnet 7.0.306
csharp 8.cs 1108ms 0.6ms 24.9MB 1093ms 0ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 46ms 0.3ms 5.3MB 40ms 0ms swift 5.8.1
csharp 8.cs 57ms 2.2ms 10.1MB 53ms 0ms dotnet/aot 7.0.306
csharp 9.cs 101ms 3.9ms 29.3MB 70ms 3ms dotnet 7.0.306
csharp 8.cs 120ms 8.5ms 29.8MB 77ms 3ms dotnet 7.0.306
csharp 8.cs 133ms 3.3ms 24.9MB 120ms 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 4565ms 6.9ms 76.2MB 4533ms 40ms dotnet/aot 7.0.306
csharp 1.cs 4718ms 42ms 98.2MB 4653ms 87ms dotnet 7.0.306
swift 1.swift timeout 0.0ms 6.7MB 4957ms 17ms swift 5.8.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 1086ms 9.4ms 75.7MB 1067ms 17ms dotnet/aot 7.0.306
csharp 1.cs 1163ms 10ms 94.9MB 1150ms 40ms dotnet 7.0.306
swift 1.swift 2426ms 2.9ms 6.3MB 2410ms 0ms swift 5.8.1