Swift VS Python benchmarks

Current benchmark data was generated on Sat Nov 16 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
python 1.py 1164ms 8.8ms 95.7MB 1100ms 47ms pypy 3.10.14
swift 1.swift 2516ms 49ms 56.6MB 2483ms 17ms swift 6.0.2
python 1.py timeout 0.0ms 40.9MB 4970ms 13ms cpython 3.13.0
python 1.py timeout 0.0ms 40.5MB 4767ms 213ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 93ms 0.7ms 67.9MB 60ms 17ms pypy 3.10.14
swift 1.swift 230ms 2.0ms 14.8MB 220ms 0ms swift 6.0.2
python 1.py 474ms 4.5ms 11.9MB 450ms 7ms pyston 3.8.12
python 1.py 716ms 13ms 12.8MB 707ms 0ms cpython 3.13.0

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2465ms 1.7ms 8.3MB 2450ms 0ms swift 6.0.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 213ms 0.4ms 8.1MB 200ms 0ms swift 6.0.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 143ms 2.7ms 27.3MB 397ms 7ms swift 6.0.2
python 1.py 1908ms 7.1ms 88.3MB 1867ms 23ms pypy 3.10.14
python 5-m.py 2493ms 42ms 12.5MB 3617ms 1003ms pyston 3.8.12
python 5-m.py 2816ms 14ms 64.9MB 3960ms 837ms pypy 3.10.14
python 1.py 3005ms 19ms 8.1MB 2993ms 0ms pyston 3.8.12
python 5-m.py 3408ms 32ms 13.8MB 4537ms 1013ms cpython 3.13.0
python 1.py 4612ms 106ms 8.8MB 4597ms 0ms cpython 3.13.0

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 37ms 0.6ms 21.1MB 33ms 0ms swift 6.0.2
python 1.py 253ms 2.4ms 63.6MB 230ms 10ms pypy 3.10.14
python 1.py 314ms 3.5ms 8.1MB 303ms 0ms pyston 3.8.12
python 5-m.py 317ms 4.6ms 12.4MB 413ms 143ms pyston 3.8.12
python 5-m.py 406ms 4.6ms 13.9MB 493ms 137ms cpython 3.13.0
python 1.py 472ms 7.6ms 8.8MB 457ms 0ms cpython 3.13.0
python 5-m.py 544ms 10ms 64.9MB 807ms 310ms pypy 3.10.14

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3.1ms 0.4ms 7.8MB 0ms 0ms swift 6.0.2
python 1.py 11ms 0.9ms 7.6MB 10ms 0ms pyston 3.8.12
python 1.py 14ms 1.1ms 8.5MB 0ms 0ms cpython 3.13.0
python 1.py 29ms 1.0ms 51.0MB 10ms 10ms pypy 3.10.14

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 1384ms 11ms 72.9MB 5030ms 33ms swift 6.0.2
python 3-m.py 2372ms 54ms 138.0MB 8053ms 343ms pypy 3.10.14
python 3-m.py 3126ms 19ms 34.1MB 11777ms 140ms pyston 3.8.12
python 3.py timeout 0.0ms 35.2MB 90ms 17ms cpython 3.13.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 261ms 1.2ms 64.3MB 680ms 33ms swift 6.0.2
python 3-m.py 375ms 2.2ms 77.1MB 933ms 163ms pypy 3.10.14
python 3-m.py 394ms 2.3ms 17.6MB 1267ms 93ms pyston 3.8.12
python 3-m.py 672ms 6.9ms 17.2MB 2367ms 60ms cpython 3.13.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 342ms 0.8ms 9.9MB 330ms 0ms swift 6.0.2
python 2.py 1351ms 7.9ms 59.8MB 1323ms 17ms pypy 3.10.14
python 1.py 2634ms 23ms 56.6MB 2610ms 10ms pypy 3.10.14
python 1.py timeout 0.0ms 8.8MB 4987ms 3ms cpython 3.13.0
python 2.py timeout 0.0ms 8.8MB 4990ms 0ms cpython 3.13.0
python 1.py timeout 0.0ms 8.3MB 4987ms 3ms pyston 3.8.12
python 2.py timeout 0.0ms 8.1MB 4987ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 40ms 0.7ms 10.1MB 30ms 0ms swift 6.0.2
python 2.py 176ms 1.4ms 57.6MB 147ms 13ms pypy 3.10.14
python 1.py 301ms 4.2ms 56.6MB 273ms 10ms pypy 3.10.14
python 1.py 926ms 8.6ms 8.3MB 910ms 0ms pyston 3.8.12
python 2.py 1297ms 12ms 8.1MB 1280ms 0ms pyston 3.8.12
python 1.py 3025ms 45ms 8.8MB 3007ms 3ms cpython 3.13.0
python 2.py 3179ms 124ms 8.8MB 3167ms 0ms cpython 3.13.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 1902ms 3.9ms 9.0MB 1867ms 20ms pyston 3.8.12
python 4.py 1960ms 11ms 9.4MB 1907ms 37ms cpython 3.13.0
python 4.py 2130ms 10ms 89.1MB 2090ms 23ms pypy 3.10.14
swift 1.swift timeout 0.0ms 10.0MB 4930ms 57ms swift 6.0.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 451ms 6.4ms 8.6MB 440ms 0ms pyston 3.8.12
python 4.py 464ms 1.8ms 9.1MB 450ms 0ms cpython 3.13.0
python 4.py 546ms 9.4ms 83.5MB 503ms 30ms pypy 3.10.14
swift 1.swift 1914ms 8.6ms 9.9MB 1897ms 3ms swift 6.0.2