Swift VS C++ benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz (Model 85)

* -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
cpp 1-im.cpp 794ms 8.7ms 3.9MB 1543ms 0ms clang++ 14.0.0
cpp 1-im.cpp 823ms 2.4ms 1.4MB 1570ms 0ms g++ 12.2.0
swift 1.swift 3536ms 37ms 2.4MB 3527ms 0ms swift 5.7.3

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 75ms 1.9ms 4.0MB 127ms 0ms clang++ 14.0.0
cpp 1-im.cpp 79ms 2.5ms 1.4MB 130ms 0ms g++ 12.2.0
swift 1.swift 293ms 2.8ms 5.2MB 283ms 0ms swift 5.7.3

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 474ms 12ms 21.1MB 630ms 10ms swift 5.7.3

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 74ms 2.7ms 14.7MB 60ms 0ms swift 5.7.3

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 2.4ms 0.7ms 1.3MB 0ms 0ms g++ 12.2.0
cpp 1.cpp 2.4ms 0.7ms 1.4MB 0ms 0ms clang++ 14.0.0
swift 1.swift 4.4ms 0.2ms 0.0MB 0ms 0ms swift 5.7.3

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 2402ms 35ms 44.4MB 4443ms 47ms swift 5.7.3

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 496ms 97ms 41.4MB 723ms 27ms swift 5.7.3

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 218ms 1.5ms 1.4MB 203ms 0ms g++ 12.2.0
cpp 0-i.cpp 253ms 4.3ms 1.4MB 243ms 0ms clang++ 14.0.0
cpp 1.cpp 413ms 9.0ms 1.4MB 400ms 0ms g++ 12.2.0
cpp 1.cpp 417ms 9.1ms 1.5MB 407ms 0ms clang++ 14.0.0
swift 7.swift 565ms 41ms 5.1MB 553ms 0ms swift 5.7.3

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 25ms 0.3ms 1.3MB 13ms 0ms g++ 12.2.0
cpp 0-i.cpp 28ms 0.2ms 1.4MB 20ms 0ms clang++ 14.0.0
cpp 1.cpp 45ms 0.3ms 1.4MB 40ms 0ms clang++ 14.0.0
cpp 1.cpp 46ms 1.9ms 1.3MB 40ms 0ms g++ 12.2.0
swift 7.swift 58ms 2.1ms 5.1MB 47ms 0ms swift 5.7.3

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift timeout 0.0ms 6.3MB 4967ms 10ms swift 5.7.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3180ms 62ms 6.2MB 3163ms 0ms swift 5.7.3