Swift VS Rust benchmarks

Current benchmark data was generated on Thu Sep 22 2022, 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.)

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 738ms 20ms 0.7MB 1410ms 0ms rustc 1.64.0
rust 2-im.rs 1077ms 9.7ms 0.7MB 2073ms 0ms rustc 1.64.0
rust 5-m.rs 1228ms 11ms 0.7MB 2377ms 0ms rustc 1.64.0
rust 3-i.rs 1374ms 0.6ms 0.6MB 1363ms 0ms rustc 1.64.0
rust 1-m.rs 1946ms 14ms 0.6MB 3797ms 0ms rustc 1.64.0
rust 2-i.rs 1997ms 1.5ms 0.6MB 1987ms 0ms rustc 1.64.0
swift 1.swift 3394ms 3.7ms 5.1MB 3383ms 0ms swift 5.7.0
rust 1.rs 3938ms 225ms 0.6MB 3927ms 0ms rustc 1.64.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 67ms 0.8ms 0.7MB 110ms 0ms rustc 1.64.0
rust 2-im.rs 97ms 0.1ms 0.7MB 160ms 0ms rustc 1.64.0
rust 3-i.rs 117ms 0.5ms 0.6MB 110ms 0ms rustc 1.64.0
rust 5-m.rs 118ms 12ms 0.7MB 190ms 0ms rustc 1.64.0
rust 2-i.rs 167ms 0.3ms 0.6MB 160ms 0ms rustc 1.64.0
rust 1-m.rs 177ms 2.0ms 0.7MB 310ms 0ms rustc 1.64.0
swift 1.swift 289ms 5.7ms 5.1MB 277ms 0ms swift 5.7.0
rust 1.rs 322ms 0.2ms 0.6MB 310ms 0ms rustc 1.64.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 179ms 1.2ms 1.2MB 320ms 0ms rustc 1.66.0-nightly
rust 5-m.rs 205ms 1.4ms 1.3MB 370ms 0ms rustc 1.64.0
rust 1c.rs 231ms 0.9ms 0.7MB 220ms 0ms rustc 1.66.0-nightly
rust 1.rs 315ms 0.4ms 0.6MB 303ms 0ms rustc 1.64.0
swift 3-m.swift 365ms 5.8ms 23.1MB 660ms 0ms swift 5.7.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1c.rs 28ms 1.5ms 0.7MB 10ms 0ms rustc 1.66.0-nightly
rust 5-m.rs 29ms 0.4ms 1.3MB 40ms 0ms rustc 1.64.0
rust 5c-m.rs 30ms 1.4ms 1.3MB 33ms 0ms rustc 1.66.0-nightly
rust 1.rs 34ms 0.2ms 0.6MB 23ms 0ms rustc 1.64.0
swift 3.swift 55ms 1.0ms 14.8MB 60ms 0ms swift 5.7.0

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 1.7ms 0.6ms 0.6MB 0ms 0ms rustc 1.66.0-nightly
rust 1.rs 1.7ms 0.6ms 0.6MB 0ms 0ms rustc 1.64.0
swift 1.swift 1.9ms 0.7ms 2.4MB 0ms 0ms swift 5.7.0

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 337ms 3.4ms 28.7MB 610ms 3ms rustc 1.64.0
rust 8.rs 592ms 4.2ms 24.0MB 577ms 3ms rustc 1.64.0
swift 2-m.swift 2092ms 20ms 46.5MB 3933ms 17ms swift 5.7.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 48ms 3.5ms 15.4MB 63ms 3ms rustc 1.64.0
rust 8.rs 76ms 0.2ms 11.5MB 57ms 3ms rustc 1.64.0
swift 2-m.swift 377ms 3.8ms 33.7MB 617ms 30ms swift 5.7.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 252ms 0.0ms 0.6MB 240ms 0ms rustc 1.64.0
rust 7-i.rs 305ms 0.6ms 0.6MB 297ms 0ms rustc 1.64.0
rust 3.rs 339ms 0.4ms 0.7MB 330ms 0ms rustc 1.66.0-nightly
rust 2.rs 345ms 1.7ms 0.6MB 333ms 0ms rustc 1.64.0
rust 1.rs 387ms 6.1ms 0.6MB 373ms 0ms rustc 1.64.0
swift 7.swift 427ms 0.9ms 5.1MB 417ms 0ms swift 5.7.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 28ms 0.2ms 0.6MB 20ms 0ms rustc 1.64.0
rust 7-i.rs 34ms 1.1ms 0.6MB 23ms 0ms rustc 1.64.0
rust 3.rs 36ms 0.4ms 0.6MB 30ms 0ms rustc 1.66.0-nightly
rust 2.rs 37ms 0.5ms 0.6MB 27ms 0ms rustc 1.64.0
rust 1.rs 41ms 0.7ms 0.6MB 30ms 0ms rustc 1.64.0
swift 7.swift 45ms 0.3ms 5.1MB 37ms 0ms swift 5.7.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 1838ms 1.3ms 2.9MB 1770ms 50ms rustc 1.64.0
rust 1.rs 1854ms 1.9ms 2.8MB 1703ms 137ms rustc 1.64.0
swift 1.swift timeout 0.0ms 0.0MB 0ms 0ms swift 5.7.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 395ms 3.1ms 2.5MB 373ms 7ms rustc 1.64.0
rust 2.rs 410ms 0.3ms 2.6MB 397ms 0ms rustc 1.64.0
swift 1.swift 2628ms 6.7ms 6.3MB 2613ms 0ms swift 5.7.0