Swift VS C benchmarks

Current benchmark data was generated on Tue Dec 31 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
swift 1.swift 2431ms 13ms 54.0MB 2407ms 7ms swift 6.0.3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 222ms 2.8ms 11.8MB 210ms 0ms swift 6.0.3

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2350ms 22ms 5.6MB 2337ms 0ms swift 6.0.3

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 199ms 1.9ms 5.6MB 190ms 0ms swift 6.0.3

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 135ms 5.7ms 24.6MB 367ms 7ms swift 6.0.3

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 35ms 0.4ms 18.3MB 33ms 0ms swift 6.0.3

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 0.9ms 0.0ms 1.4MB 0ms 0ms zigcc 0.13.0
c 1.c 1.2ms 0.0ms 2.1MB 0ms 0ms gcc 14.2.0
c 1.c 1.3ms 0.2ms 2.1MB 0ms 0ms clang 14.0.0-1ubuntu1.1
swift 1.swift 2.4ms 0.2ms 6.0MB 0ms 0ms swift 6.0.3

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 175ms 15ms 26.1MB 410ms 7ms gcc 14.2.0
c 1-m.c 282ms 6.9ms 29.6MB 953ms 30ms clang 14.0.0-1ubuntu1.1
swift 2-m.swift 1324ms 22ms 74.6MB 4820ms 30ms swift 6.0.3

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 27ms 0.6ms 13.2MB 57ms 3ms gcc 14.2.0
c 1-m.c 35ms 1.3ms 14.9MB 103ms 0ms clang 14.0.0-1ubuntu1.1
swift 2-m.swift 250ms 3.1ms 63.8MB 653ms 30ms swift 6.0.3

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 233ms 2.3ms 1.5MB 223ms 0ms zigcc 0.13.0
c 5.c 280ms 2.5ms 1.5MB 270ms 0ms zigcc 0.13.0
c 8-i.c 289ms 1.5ms 2.1MB 280ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 291ms 2.9ms 2.3MB 280ms 0ms gcc 14.2.0
c 2.c 297ms 4.6ms 1.5MB 287ms 0ms zigcc 0.13.0
c 5.c 300ms 5.4ms 2.3MB 287ms 0ms gcc 14.2.0
c 5.c 301ms 3.6ms 2.1MB 293ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 303ms 3.9ms 2.1MB 293ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 317ms 4.6ms 2.3MB 307ms 0ms gcc 14.2.0
swift 7.swift 329ms 4.6ms 9.6MB 317ms 0ms swift 6.0.3

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 26ms 0.1ms 1.5MB 20ms 0ms zigcc 0.13.0
c 5.c 30ms 0.2ms 1.5MB 20ms 0ms zigcc 0.13.0
c 8-i.c 30ms 0.4ms 2.1MB 20ms 0ms clang 14.0.0-1ubuntu1.1
c 2.c 31ms 0.4ms 1.5MB 20ms 0ms zigcc 0.13.0
c 2.c 31ms 0.4ms 2.3MB 20ms 0ms gcc 14.2.0
c 5.c 32ms 0.8ms 2.1MB 20ms 0ms clang 14.0.0-1ubuntu1.1
c 5.c 32ms 0.5ms 2.3MB 20ms 0ms gcc 14.2.0
c 2.c 33ms 1.7ms 2.1MB 23ms 0ms clang 14.0.0-1ubuntu1.1
c 8-i.c 33ms 0.3ms 2.3MB 23ms 0ms gcc 14.2.0
swift 7.swift 37ms 0.6ms 9.8MB 23ms 0ms swift 6.0.3

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift timeout 0.0ms 7.4MB 4913ms 70ms swift 6.0.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 1766ms 11ms 6.9MB 1753ms 0ms swift 6.0.3