Swift VS Python benchmarks

Current benchmark data was generated on Tue Mar 25 2025, 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 1197ms 3.3ms 96.2MB 1130ms 53ms pypy 3.10.16
swift 1.swift 2950ms 76ms 53.9MB 2917ms 20ms swift 6.0.3
python 1.py timeout 0.0ms 40.8MB 4967ms 17ms cpython 3.13.2
python 1.py timeout 0.0ms 40.5MB 4740ms 250ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 97ms 2.2ms 68.7MB 67ms 17ms pypy 3.10.16
swift 1.swift 237ms 1.1ms 11.9MB 227ms 0ms swift 6.0.3
python 1.py 487ms 1.2ms 11.9MB 460ms 13ms pyston 3.8.12
python 1.py 726ms 15ms 12.6MB 713ms 0ms cpython 3.13.2

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2483ms 17ms 5.6MB 2473ms 0ms swift 6.0.3

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 214ms 1.8ms 6.3MB 207ms 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 1.1ms 20.9MB 387ms 0ms swift 6.0.3
python 1.py 1866ms 18ms 88.8MB 1820ms 33ms pypy 3.10.16
python 5-m.py 2278ms 15ms 65.4MB 3513ms 857ms pypy 3.10.16
python 5-m.py 2482ms 19ms 12.5MB 3550ms 1030ms pyston 3.8.12
python 1.py 3030ms 3.8ms 8.1MB 3020ms 0ms pyston 3.8.12
python 5-m.py 3399ms 44ms 13.5MB 4503ms 963ms cpython 3.13.2
python 1.py 4712ms 79ms 8.8MB 4703ms 0ms cpython 3.13.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 36ms 0.3ms 18.3MB 30ms 0ms swift 6.0.3
python 1.py 249ms 2.9ms 63.3MB 220ms 13ms pypy 3.10.16
python 1.py 317ms 7.5ms 8.1MB 303ms 0ms pyston 3.8.12
python 5-m.py 321ms 4.6ms 12.5MB 420ms 147ms pyston 3.8.12
python 5-m.py 405ms 4.6ms 13.5MB 490ms 133ms cpython 3.13.2
python 5-m.py 450ms 2.3ms 65.4MB 730ms 327ms pypy 3.10.16
python 1.py 484ms 3.0ms 8.8MB 473ms 0ms cpython 3.13.2

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2.5ms 0.2ms 5.9MB 0ms 0ms swift 6.0.3
python 1.py 12ms 0.8ms 7.6MB 0ms 0ms pyston 3.8.12
python 1.py 14ms 1.2ms 8.6MB 10ms 0ms cpython 3.13.2
python 1.py 30ms 1.2ms 51.4MB 10ms 10ms pypy 3.10.16

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 1390ms 6.6ms 74.5MB 5083ms 30ms swift 6.0.3
python 3-m.py 2464ms 33ms 136.4MB 8333ms 327ms pypy 3.10.16
python 3-m.py 3223ms 25ms 34.3MB 12263ms 117ms pyston 3.8.12
python 3.py timeout 0.0ms 35.6MB 87ms 23ms cpython 3.13.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 263ms 1.7ms 60.0MB 693ms 23ms swift 6.0.3
python 3-m.py 392ms 2.5ms 76.3MB 1003ms 160ms pypy 3.10.16
python 3-m.py 406ms 1.5ms 14.3MB 1347ms 70ms pyston 3.8.12
python 3-m.py 659ms 5.8ms 15.1MB 2317ms 63ms cpython 3.13.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 345ms 1.2ms 9.8MB 340ms 0ms swift 6.0.3
python 2.py 1357ms 7.5ms 57.9MB 1330ms 10ms pypy 3.10.16
python 1.py 2662ms 11ms 57.2MB 2640ms 10ms pypy 3.10.16
python 1.py timeout 0.0ms 8.8MB 4990ms 0ms cpython 3.13.2
python 2.py timeout 0.0ms 8.8MB 4990ms 0ms cpython 3.13.2
python 1.py timeout 0.0ms 8.3MB 4990ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 8.1MB 4990ms 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.2ms 9.8MB 30ms 0ms swift 6.0.3
python 2.py 179ms 2.5ms 57.9MB 157ms 10ms pypy 3.10.16
python 1.py 310ms 12ms 57.0MB 287ms 10ms pypy 3.10.16
python 1.py 934ms 14ms 8.3MB 920ms 0ms pyston 3.8.12
python 2.py 1326ms 45ms 8.1MB 1313ms 0ms pyston 3.8.12
python 1.py 3035ms 123ms 8.6MB 3020ms 0ms cpython 3.13.2
python 2.py 3207ms 87ms 8.8MB 3197ms 0ms cpython 3.13.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 1912ms 9.2ms 8.9MB 1870ms 27ms pyston 3.8.12
python 4.py 1956ms 14ms 9.3MB 1890ms 47ms cpython 3.13.2
python 4.py 2197ms 12ms 89.4MB 2153ms 30ms pypy 3.10.16
swift 1.swift timeout 0.0ms 7.1MB 4910ms 70ms swift 6.0.3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 453ms 3.4ms 8.6MB 443ms 0ms pyston 3.8.12
python 4.py 463ms 0.7ms 9.1MB 450ms 0ms cpython 3.13.2
python 4.py 551ms 4.4ms 83.8MB 517ms 20ms pypy 3.10.16
swift 1.swift 1877ms 8.7ms 7.0MB 1863ms 0ms swift 6.0.3