Swift VS Rust benchmarks

Current benchmark data was generated on Sun Dec 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
rust 4.rs 1251ms 6.0ms 33.8MB 1233ms 7ms rustc 1.83.0
rust 5.rs 1378ms 31ms 33.8MB 1357ms 10ms rustc 1.83.0
rust 3.rs 1482ms 30ms 49.8MB 1443ms 23ms rustc 1.83.0
swift 1.swift 2834ms 94ms 54.3MB 2803ms 13ms swift 6.0.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5.rs 123ms 0.3ms 5.8MB 110ms 0ms rustc 1.83.0
rust 4.rs 129ms 19ms 5.8MB 120ms 0ms rustc 1.83.0
rust 3.rs 142ms 4.7ms 7.8MB 130ms 0ms rustc 1.83.0
swift 1.swift 229ms 2.2ms 12.5MB 217ms 0ms swift 6.0.2

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 413ms 6.2ms 4.0MB 1573ms 0ms rustc 1.83.0
rust 5-m.rs 567ms 6.5ms 4.0MB 2143ms 3ms rustc 1.83.0
rust 2-im.rs 629ms 1.2ms 6.0MB 2387ms 0ms rustc 1.83.0
rust 1-m.rs 997ms 11ms 6.0MB 3850ms 0ms rustc 1.83.0
rust 3-i.rs 1489ms 1.2ms 1.9MB 1480ms 0ms rustc 1.83.0
rust 2-i.rs 1754ms 1.4ms 1.8MB 1740ms 0ms rustc 1.83.0
swift 1.swift 2463ms 5.8ms 6.6MB 2453ms 0ms swift 6.0.2
rust 1.rs 2669ms 15ms 1.8MB 2657ms 0ms rustc 1.83.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 38ms 0.3ms 4.0MB 117ms 3ms rustc 1.83.0
rust 5-m.rs 56ms 0.8ms 6.0MB 170ms 0ms rustc 1.83.0
rust 2-im.rs 62ms 1.1ms 6.0MB 200ms 0ms rustc 1.83.0
rust 1-m.rs 88ms 1.9ms 6.0MB 307ms 0ms rustc 1.83.0
rust 3-i.rs 124ms 0.4ms 1.9MB 117ms 0ms rustc 1.83.0
rust 2-i.rs 149ms 0.8ms 1.8MB 140ms 0ms rustc 1.83.0
swift 1.swift 211ms 1.2ms 5.8MB 200ms 0ms swift 6.0.2
rust 1.rs 223ms 0.6ms 1.8MB 210ms 0ms rustc 1.83.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 91ms 2.5ms 4.8MB 240ms 7ms rustc 1.83.0
rust 5-m.rs 98ms 0.2ms 6.5MB 320ms 0ms rustc 1.83.0
swift 3-m.swift 145ms 2.8ms 25.0MB 413ms 10ms swift 6.0.2
rust 1c.rs 162ms 0.1ms 1.9MB 150ms 0ms rustc 1.83.0
rust 1.rs 193ms 1.6ms 1.9MB 180ms 0ms rustc 1.83.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 16ms 0.2ms 4.8MB 20ms 3ms rustc 1.83.0
rust 5-m.rs 17ms 0.2ms 4.8MB 30ms 0ms rustc 1.83.0
rust 1c.rs 19ms 0.2ms 1.9MB 10ms 0ms rustc 1.83.0
rust 1.rs 22ms 0.3ms 1.9MB 10ms 0ms rustc 1.83.0
swift 3.swift 38ms 0.6ms 18.3MB 33ms 0ms swift 6.0.2

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1.3ms 0.0ms 1.8MB 0ms 0ms rustc 1.83.0
rust 1.rs 1.3ms 0.0ms 1.8MB 0ms 0ms rustc 1.85.0-nightly
swift 1.swift 2.7ms 0.3ms 6.3MB 0ms 0ms swift 6.0.2

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 226ms 10ms 30.0MB 647ms 17ms rustc 1.83.0
rust 8.rs 503ms 36ms 23.9MB 480ms 7ms rustc 1.83.0
swift 2-m.swift 1595ms 233ms 72.7MB 5200ms 33ms swift 6.0.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 34ms 1.4ms 15.7MB 63ms 3ms rustc 1.83.0
rust 8.rs 60ms 0.3ms 11.5MB 47ms 3ms rustc 1.83.0
swift 2-m.swift 271ms 3.1ms 64.1MB 687ms 40ms swift 6.0.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 165ms 3.7ms 1.9MB 153ms 0ms rustc 1.83.0
rust 7-i.rs 236ms 0.8ms 1.8MB 227ms 0ms rustc 1.83.0
rust 1.rs 238ms 0.5ms 1.8MB 230ms 0ms rustc 1.83.0
rust 2.rs 279ms 0.3ms 1.8MB 267ms 0ms rustc 1.83.0
rust 3.rs 280ms 0.4ms 1.9MB 270ms 0ms rustc 1.85.0-nightly
swift 7.swift 347ms 7.9ms 10.0MB 333ms 0ms swift 6.0.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 19ms 0.4ms 1.8MB 10ms 0ms rustc 1.83.0
rust 1.rs 26ms 0.1ms 1.8MB 17ms 0ms rustc 1.83.0
rust 7-i.rs 26ms 0.2ms 1.8MB 13ms 0ms rustc 1.83.0
rust 2.rs 30ms 0.1ms 1.8MB 20ms 0ms rustc 1.83.0
rust 3.rs 30ms 0.2ms 1.9MB 20ms 0ms rustc 1.85.0-nightly
swift 7.swift 41ms 0.1ms 10.1MB 30ms 0ms swift 6.0.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1519ms 2.0ms 2.8MB 1257ms 243ms rustc 1.83.0
rust 2.rs 1706ms 6.4ms 2.8MB 1613ms 73ms rustc 1.83.0
swift 1.swift timeout 0.0ms 7.5MB 4933ms 53ms swift 6.0.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 320ms 1.6ms 2.4MB 290ms 17ms rustc 1.83.0
rust 2.rs 379ms 3.1ms 2.5MB 360ms 3ms rustc 1.83.0
swift 1.swift 1947ms 10ms 7.3MB 1933ms 0ms swift 6.0.2