Swift VS C# benchmarks

Current benchmark data was generated on Thu Feb 01 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 1213ms 21ms 132.8MB 1443ms 180ms dotnet/aot 8.0.101
csharp 1.cs 1714ms 70ms 109.8MB 1903ms 220ms mono 6.12.0
csharp 1.cs 1868ms 70ms 2126.1MB 710ms 1117ms dotnet 8.0.101
swift 1.swift 2063ms 7.6ms 56.6MB 2023ms 23ms swift 5.9.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 92ms 2.7ms 29.1MB 93ms 13ms dotnet/aot 8.0.101
csharp 1.cs 142ms 1.4ms 44.9MB 117ms 13ms mono 6.12.0
swift 1.swift 195ms 3.0ms 14.5MB 180ms 0ms swift 5.9.2
csharp 1.cs 283ms 5.7ms 229.7MB 130ms 113ms dotnet 8.0.101

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2453ms 7.0ms 8.5MB 2443ms 0ms swift 5.9.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 212ms 1.3ms 8.4MB 200ms 0ms swift 5.9.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 133ms 7.9ms 36.2MB 380ms 83ms dotnet/aot 8.0.101
csharp 5-m.cs 205ms 9.6ms 45.3MB 477ms 117ms dotnet 8.0.101
swift 3-m.swift 209ms 1.1ms 28.8MB 520ms 7ms swift 5.9.2
csharp 5-m.cs 262ms 5.6ms 47.9MB 683ms 147ms mono 6.12.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 5-m.cs 34ms 1.8ms 27.0MB 50ms 27ms dotnet/aot 8.0.101
swift 3.swift 45ms 0.5ms 18.4MB 43ms 0ms swift 5.9.2
csharp 5-m.cs 85ms 10ms 42.7MB 110ms 30ms mono 6.12.0
csharp 5.cs 86ms 6.4ms 42.0MB 83ms 20ms dotnet 8.0.101

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3.0ms 0.2ms 7.6MB 0ms 0ms swift 5.9.2
csharp 1.cs 12ms 11ms 16.2MB 0ms 0ms dotnet/aot 8.0.101
csharp 1.cs 32ms 0.5ms 23.8MB 18ms 2ms mono 6.12.0
csharp 1.cs 56ms 6.0ms 31.4MB 20ms 2ms dotnet 8.0.101

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 511ms 13ms 56.0MB 1300ms 30ms dotnet/aot 8.0.101
csharp 6-m.cs 629ms 31ms 82.6MB 1287ms 43ms dotnet 8.0.101
csharp 6-m.cs 1015ms 14ms 69.1MB 2943ms 27ms mono 6.12.0
swift 2-m.swift 1458ms 77ms 72.0MB 5233ms 37ms swift 5.9.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 6-m.cs 98ms 5.9ms 46.2MB 173ms 23ms dotnet/aot 8.0.101
csharp 6.cs 167ms 13ms 72.2MB 207ms 30ms dotnet 8.0.101
csharp 6-m.cs 198ms 0.7ms 57.8MB 380ms 20ms mono 6.12.0
swift 2-m.swift 262ms 1.4ms 63.5MB 697ms 20ms swift 5.9.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 355ms 2.9ms 9.4MB 340ms 0ms swift 5.9.2
csharp 8.cs 375ms 1.6ms 14.2MB 370ms 3ms dotnet/aot 8.0.101
csharp 9.cs 383ms 7.2ms 33.1MB 343ms 10ms dotnet 8.0.101
csharp 8.cs 433ms 3.3ms 32.9MB 393ms 7ms dotnet 8.0.101
csharp 8.cs 1248ms 6.8ms 24.9MB 1230ms 3ms mono 6.12.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 8.cs 48ms 1.3ms 16.1MB 43ms 3ms dotnet/aot 8.0.101
swift 7.swift 50ms 8.4ms 9.4MB 40ms 0ms swift 5.9.2
csharp 8.cs 106ms 7.9ms 33.2MB 67ms 10ms dotnet 8.0.101
csharp 9.cs 114ms 2.8ms 33.1MB 77ms 10ms dotnet 8.0.101
csharp 8.cs 162ms 1.0ms 27.0MB 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 3233ms 16ms 19.9MB 3110ms 137ms dotnet/aot 8.0.101
csharp 1.cs timeout 0.0ms 4256.5MB 3027ms 1923ms dotnet 8.0.101
swift 1.swift timeout 0.0ms 9.9MB 4923ms 60ms swift 5.9.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
csharp 1.cs 760ms 5.7ms 19.4MB 723ms 33ms dotnet/aot 8.0.101
csharp 1.cs 1552ms 36ms 1164.4MB 1013ms 597ms dotnet 8.0.101
swift 1.swift 1891ms 15ms 9.8MB 1873ms 0ms swift 5.9.2