Swift VS Rust benchmarks

Current benchmark data was generated on Fri May 20 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 726ms 2.1ms 0.7MB 1407ms 0ms rustc 1.61.0
rust 2-im.rs 1043ms 7.2ms 0.6MB 2010ms 0ms rustc 1.61.0
rust 5-m.rs 1222ms 14ms 0.7MB 2350ms 0ms rustc 1.61.0
rust 3-i.rs 1429ms 4.8ms 0.6MB 1417ms 0ms rustc 1.61.0
rust 2-i.rs 1865ms 8.9ms 0.6MB 1857ms 0ms rustc 1.61.0
rust 1-m.rs 2009ms 8.0ms 0.7MB 3873ms 0ms rustc 1.61.0
swift 1.swift 3451ms 12ms 5.4MB 3427ms 3ms swift 5.6.1
rust 1.rs 3709ms 24ms 0.6MB 3697ms 0ms rustc 1.61.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 3-im.rs 67ms 0.7ms 0.7MB 110ms 0ms rustc 1.61.0
rust 2-im.rs 94ms 1.9ms 0.7MB 160ms 0ms rustc 1.61.0
rust 5-m.rs 112ms 0.6ms 0.7MB 190ms 0ms rustc 1.61.0
rust 3-i.rs 121ms 1.5ms 0.6MB 110ms 0ms rustc 1.61.0
rust 2-i.rs 156ms 1.3ms 0.6MB 147ms 0ms rustc 1.61.0
rust 1-m.rs 178ms 3.1ms 0.7MB 317ms 0ms rustc 1.61.0
swift 1.swift 302ms 17ms 5.2MB 280ms 0ms swift 5.6.1
rust 1.rs 326ms 12ms 0.6MB 317ms 0ms rustc 1.61.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 5c-m.rs 180ms 3.2ms 1.3MB 313ms 3ms rustc 1.63.0
rust 5-m.rs 206ms 1.1ms 1.3MB 370ms 0ms rustc 1.61.0
rust 1c.rs 234ms 0.2ms 0.7MB 227ms 0ms rustc 1.63.0
rust 1.rs 315ms 0.7ms 0.6MB 307ms 0ms rustc 1.61.0
swift 3-m.swift 369ms 4.6ms 21.0MB 663ms 7ms swift 5.6.1

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1c.rs 28ms 2.3ms 0.7MB 20ms 0ms rustc 1.63.0
rust 5c-m.rs 29ms 2.8ms 1.3MB 33ms 0ms rustc 1.63.0
rust 5-m.rs 29ms 1.4ms 1.3MB 33ms 0ms rustc 1.61.0
rust 1.rs 35ms 1.1ms 2.1MB 23ms 0ms rustc 1.61.0
swift 3.swift 64ms 15ms 14.6MB 60ms 0ms swift 5.6.1

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 2.1ms 1.0ms 0.6MB 0ms 0ms rustc 1.63.0
rust 1.rs 6.1ms 9.2ms 0.6MB 0ms 0ms rustc 1.61.0
swift 1.swift 7.3ms 9.6ms 4.8MB 0ms 0ms swift 5.6.1

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 350ms 7.7ms 29.1MB 603ms 17ms rustc 1.61.0
rust 8.rs 615ms 8.3ms 23.2MB 593ms 10ms rustc 1.61.0
swift 2-m.swift 2306ms 390ms 54.4MB 3920ms 23ms swift 5.6.1

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 8-m.rs 50ms 2.3ms 16.0MB 70ms 3ms rustc 1.61.0
rust 8.rs 76ms 0.9ms 11.6MB 57ms 3ms rustc 1.61.0
swift 2-m.swift 385ms 25ms 33.7MB 637ms 10ms swift 5.6.1

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 253ms 0.8ms 0.6MB 240ms 0ms rustc 1.61.0
rust 7-i.rs 305ms 0.2ms 0.6MB 290ms 0ms rustc 1.61.0
rust 3.rs 319ms 0.2ms 0.6MB 310ms 0ms rustc 1.63.0
rust 2.rs 347ms 9.0ms 0.6MB 337ms 0ms rustc 1.61.0
rust 1.rs 390ms 11ms 0.6MB 377ms 0ms rustc 1.61.0
swift 7.swift 426ms 0.4ms 5.4MB 417ms 0ms swift 5.6.1

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 4-i.rs 29ms 1.4ms 0.6MB 20ms 0ms rustc 1.61.0
rust 7-i.rs 33ms 1.1ms 0.6MB 23ms 0ms rustc 1.61.0
rust 3.rs 35ms 1.8ms 0.6MB 30ms 0ms rustc 1.63.0
rust 1.rs 42ms 1.4ms 0.6MB 30ms 0ms rustc 1.61.0
rust 2.rs 50ms 12ms 0.6MB 40ms 0ms rustc 1.61.0
swift 7.swift 55ms 14ms 5.4MB 40ms 0ms swift 5.6.1

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 2.rs 1829ms 0.8ms 2.8MB 1750ms 67ms rustc 1.61.0
rust 1.rs 1829ms 0.7ms 2.9MB 1670ms 143ms rustc 1.61.0
swift 1.swift timeout 0.0ms 0.0MB 0ms 0ms swift 5.6.1

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
rust 1.rs 390ms 0.6ms 2.6MB 373ms 0ms rustc 1.61.0
rust 2.rs 409ms 0.9ms 2.6MB 397ms 0ms rustc 1.61.0
swift 1.swift 3474ms 78ms 6.4MB 3450ms 0ms swift 5.6.1