Swift VS Python benchmarks

Current benchmark data was generated on Thu Feb 01 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 1568ms 90ms 79.1MB 1510ms 40ms pypy 3.10.13
swift 1.swift 2063ms 7.6ms 56.6MB 2023ms 23ms swift 5.9.2
python 1.py timeout 0.0ms 41.3MB 4977ms 10ms cpython 3.12.1
python 1.py timeout 0.0ms 40.5MB 4763ms 223ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 116ms 0.7ms 62.6MB 80ms 20ms pypy 3.10.13
swift 1.swift 195ms 3.0ms 14.5MB 180ms 0ms swift 5.9.2
python 1.py 478ms 4.3ms 11.9MB 450ms 13ms pyston 3.8.12
python 1.py 732ms 6.5ms 13.1MB 713ms 0ms cpython 3.12.1

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 2453ms 7.0ms 8.5MB 2443ms 0ms swift 5.9.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 212ms 1.3ms 8.4MB 200ms 0ms swift 5.9.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3-m.swift 209ms 1.1ms 28.8MB 520ms 7ms swift 5.9.2
python 1.py 1945ms 8.0ms 62.7MB 1917ms 10ms pypy 3.10.13
python 5-m.py 2465ms 14ms 12.4MB 3553ms 1027ms pyston 3.8.12
python 5-m.py 2926ms 14ms 63.1MB 4217ms 773ms pypy 3.10.13
python 1.py 3002ms 24ms 8.1MB 2987ms 0ms pyston 3.8.12
python 5-m.py 3316ms 15ms 14.3MB 4393ms 993ms cpython 3.12.1
python 1.py 4481ms 71ms 9.3MB 4473ms 0ms cpython 3.12.1

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 3.swift 45ms 0.5ms 18.4MB 43ms 0ms swift 5.9.2
python 1.py 267ms 4.6ms 61.3MB 240ms 7ms pypy 3.10.13
python 5-m.py 314ms 12ms 12.5MB 407ms 147ms pyston 3.8.12
python 1.py 316ms 1.5ms 8.1MB 303ms 3ms pyston 3.8.12
python 5-m.py 401ms 1.6ms 14.3MB 463ms 167ms cpython 3.12.1
python 1.py 469ms 14ms 9.3MB 457ms 0ms cpython 3.12.1
python 5-m.py 657ms 11ms 63.1MB 880ms 367ms pypy 3.10.13

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 1.swift 3.0ms 0.2ms 7.6MB 0ms 0ms swift 5.9.2
python 1.py 12ms 0.9ms 7.6MB 0ms 0ms pyston 3.8.12
python 1.py 14ms 1.3ms 9.0MB 0ms 0ms cpython 3.12.1
python 1.py 30ms 1.2ms 48.6MB 8ms 8ms pypy 3.10.13

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 1458ms 77ms 72.0MB 5233ms 37ms swift 5.9.2
python 3-m.py 2331ms 35ms 135.9MB 7750ms 343ms pypy 3.10.13
python 3-m.py 3289ms 49ms 34.2MB 12493ms 123ms pyston 3.8.12
python 3.py timeout 0.0ms 35.9MB 87ms 27ms cpython 3.12.1

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 2-m.swift 262ms 1.4ms 63.5MB 697ms 20ms swift 5.9.2
python 3-m.py 404ms 0.9ms 17.7MB 1333ms 70ms pyston 3.8.12
python 3-m.py 409ms 2.6ms 71.4MB 1023ms 163ms pypy 3.10.13
python 3-m.py 694ms 3.6ms 17.5MB 2423ms 80ms cpython 3.12.1

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 355ms 2.9ms 9.4MB 340ms 0ms swift 5.9.2
python 2.py 1386ms 17ms 60.4MB 1357ms 17ms pypy 3.10.13
python 1.py 2647ms 17ms 54.1MB 2617ms 10ms pypy 3.10.13
python 1.py timeout 0.0ms 9.1MB 4987ms 0ms cpython 3.12.1
python 2.py timeout 0.0ms 9.3MB 4990ms 0ms cpython 3.12.1
python 1.py timeout 0.0ms 8.3MB 4980ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 8.1MB 4983ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
swift 7.swift 50ms 8.4ms 9.4MB 40ms 0ms swift 5.9.2
python 2.py 179ms 0.4ms 55.8MB 153ms 10ms pypy 3.10.13
python 1.py 305ms 5.4ms 54.0MB 283ms 10ms pypy 3.10.13
python 1.py 942ms 43ms 8.3MB 930ms 0ms pyston 3.8.12
python 2.py 1314ms 31ms 8.1MB 1300ms 0ms pyston 3.8.12
python 1.py 2986ms 131ms 9.1MB 2973ms 0ms cpython 3.12.1
python 2.py 3077ms 2.2ms 9.1MB 3063ms 0ms cpython 3.12.1

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 1897ms 5.0ms 8.9MB 1850ms 30ms pyston 3.8.12
python 4.py 1959ms 2.6ms 9.9MB 1910ms 33ms cpython 3.12.1
python 4.py 2334ms 11ms 63.4MB 2280ms 37ms pypy 3.10.13
swift 1.swift timeout 0.0ms 9.9MB 4923ms 60ms swift 5.9.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 450ms 3.6ms 8.8MB 433ms 0ms pyston 3.8.12
python 4.py 466ms 5.6ms 9.6MB 450ms 0ms cpython 3.12.1
python 4.py 569ms 8.0ms 61.9MB 537ms 13ms pypy 3.10.13
swift 1.swift 1891ms 15ms 9.8MB 1873ms 0ms swift 5.9.2