Python VS Perl benchmarks

Current benchmark data was generated on Fri Dec 09 2022, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL 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.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1587ms 15ms 217.5MB 1427ms 143ms pypy 3.9.15
perl 1.pl timeout 0.0ms 0.0MB 0ms 0ms perl 5.36.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 117ms 0.9ms 74.5MB 87ms 13ms pypy 3.9.15
python 1.py 662ms 1.2ms 12.0MB 643ms 3ms pyston 3.8.12
python 1.py 994ms 8.9ms 12.5MB 977ms 0ms cpython 3.11.1
perl 1.pl 2180ms 16ms 14.1MB 2170ms 0ms perl 5.36.0

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1264ms 42ms 230.0MB 1163ms 90ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 266ms 3.4ms 87.9MB 230ms 20ms pypy 3.9.15
python 1.py 791ms 4.2ms 20.1MB 770ms 3ms cpython 3.11.1
python 1.py 858ms 3.1ms 16.9MB 830ms 10ms pyston 3.8.12

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 588ms 0.8ms 78.8MB 563ms 7ms pypy 3.9.15
python 1.py 1402ms 0.8ms 10.1MB 1390ms 0ms cpython 3.11.1
python 1.py 2296ms 0.6ms 9.7MB 2280ms 3ms pyston 3.8.12

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 162ms 0.8ms 73.3MB 133ms 13ms pypy 3.9.15
python 1.py 261ms 0.9ms 9.3MB 247ms 0ms cpython 3.11.1
python 1.py 402ms 0.7ms 9.0MB 387ms 0ms pyston 3.8.12

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 2815ms 14ms 85.1MB 2773ms 20ms pypy 3.9.15
python 5-m.py 3333ms 29ms 12.8MB 4747ms 1223ms pyston 3.8.12
python 1.py 3912ms 11ms 7.9MB 3897ms 0ms pyston 3.8.12
python 5-m.py 3960ms 7.9ms 13.5MB 5677ms 1140ms cpython 3.11.1
python 5-m.py 4193ms 20ms 76.0MB 5597ms 1210ms pypy 3.9.15
perl 1.pl 4421ms 96ms 10.9MB 4400ms 0ms perl 5.36.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 350ms 1.8ms 73.9MB 317ms 17ms pypy 3.9.15
python 5-m.py 399ms 3.3ms 12.7MB 507ms 153ms pyston 3.8.12
python 1.py 409ms 1.9ms 8.0MB 393ms 0ms pyston 3.8.12
perl 1.pl 443ms 1.2ms 6.7MB 427ms 0ms perl 5.36.0
python 5-m.py 462ms 0.8ms 13.5MB 600ms 143ms cpython 3.11.1
python 1.py 600ms 2.8ms 8.6MB 583ms 0ms cpython 3.11.1
python 5-m.py 766ms 2.2ms 76.1MB 820ms 450ms pypy 3.9.15

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
perl 1.pl 3.2ms 0.6ms 4.9MB 0ms 0ms perl 5.36.0
python 1.py 13ms 1.1ms 8.5MB 10ms 0ms cpython 3.11.1
python 1.py 14ms 2.5ms 7.3MB 10ms 0ms pyston 3.8.12
python 1.py 33ms 0.8ms 52.8MB 14ms 8ms pypy 3.9.15

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1685ms 11ms 35.4MB 1283ms 863ms pyston 3.8.12
python 1.py 2008ms 14ms 29.7MB 1547ms 943ms cpython 3.11.1
python 1.py 4531ms 53ms 122.1MB 3437ms 927ms pypy 3.9.15

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 375ms 2.4ms 28.2MB 287ms 153ms pyston 3.8.12
python 1.py 401ms 4.2ms 24.8MB 307ms 160ms cpython 3.11.1
python 1.py 1065ms 17ms 96.9MB 827ms 197ms pypy 3.9.15

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 259ms 1.1ms 38.9MB 217ms 27ms pyston 3.8.12
python 1.py 276ms 8.5ms 41.3MB 237ms 20ms cpython 3.11.1
python 1.py 399ms 3.0ms 98.7MB 343ms 40ms pypy 3.9.15

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 2440ms 6.1ms 220.7MB 2250ms 177ms pyston 3.8.12
python 1.py 2441ms 5.5ms 223.2MB 2323ms 103ms cpython 3.11.1
python 1.py 2639ms 52ms 239.6MB 2543ms 77ms pypy 3.9.15

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 3-m.py 4154ms 68ms 210.6MB 7280ms 417ms pypy 3.9.15
python 3.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 3.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 3-m.py 568ms 5.4ms 86.3MB 840ms 120ms pypy 3.9.15
python 3-m.py 605ms 10ms 15.6MB 1070ms 23ms pyston 3.8.12
python 3-m.py 829ms 5.4ms 16.9MB 1490ms 33ms cpython 3.11.1

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 223ms 0.7ms 70.8MB 190ms 17ms pypy 3.9.15
python 1.py 264ms 2.2ms 72.0MB 237ms 7ms pypy 3.9.15
python 1.py 935ms 11ms 9.1MB 927ms 0ms pyston 3.8.12
python 2.py 1073ms 3.0ms 8.8MB 1060ms 0ms pyston 3.8.12
python 1.py 1244ms 8.5ms 9.3MB 1227ms 0ms cpython 3.11.1
python 2.py 1441ms 18ms 9.1MB 1427ms 0ms cpython 3.11.1

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 552ms 9.8ms 71.2MB 513ms 13ms pypy 3.9.15
python 1.py 591ms 1.5ms 72.2MB 570ms 10ms pypy 3.9.15
python 1.py 2755ms 9.8ms 9.0MB 2737ms 0ms pyston 3.8.12
python 2.py 3191ms 6.2ms 8.8MB 3177ms 0ms pyston 3.8.12
python 1.py 3714ms 24ms 9.4MB 3697ms 0ms cpython 3.11.1
python 2.py 4286ms 40ms 9.1MB 4273ms 0ms cpython 3.11.1

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 155ms 2.5ms 71.3MB 123ms 13ms pypy 3.9.15
python 1.py 172ms 0.5ms 72.5MB 147ms 10ms pypy 3.9.15
python 1.py 449ms 2.8ms 8.7MB 430ms 0ms pyston 3.8.12
python 2.py 502ms 1.9ms 8.2MB 490ms 0ms pyston 3.8.12
python 1.py 591ms 3.1ms 8.7MB 580ms 0ms cpython 3.11.1
python 2.py 714ms 9.6ms 8.4MB 697ms 0ms cpython 3.11.1

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 2452ms 8.9ms 230.3MB 2283ms 150ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 374ms 4.2ms 149.8MB 310ms 47ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 1980ms 13ms 71.2MB 1947ms 17ms pypy 3.9.15
python 1.py 3619ms 6.8ms 70.3MB 3590ms 10ms pypy 3.9.15
perl 2.pl timeout 0.0ms 0.0MB 0ms 0ms perl 5.36.0
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 2.py 251ms 1.7ms 70.9MB 223ms 10ms pypy 3.9.15
python 1.py 409ms 0.4ms 70.2MB 387ms 10ms pypy 3.9.15
python 1.py 1182ms 5.1ms 8.3MB 1167ms 0ms pyston 3.8.12
python 2.py 1652ms 71ms 7.9MB 1640ms 0ms pyston 3.8.12
perl 2.pl 3095ms 84ms 6.2MB 3083ms 0ms perl 5.36.0
python 1.py 3191ms 127ms 8.4MB 3180ms 0ms cpython 3.11.1
python 2.py 3533ms 39ms 8.7MB 3517ms 0ms cpython 3.11.1

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 4853ms 9.3ms 382.9MB 4680ms 157ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 2.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 2.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1064ms 19ms 207.0MB 990ms 57ms pypy 3.9.15
python 2.py 1144ms 11ms 164.4MB 1053ms 73ms pyston 3.8.12
python 2.py 1677ms 23ms 164.7MB 1587ms 70ms cpython 3.11.1
python 2.py 1844ms 9.4ms 210.2MB 1697ms 130ms pypy 3.9.15
python 1.py 2042ms 2.5ms 86.0MB 1997ms 27ms pyston 3.8.12
python 1.py 3574ms 32ms 86.8MB 3527ms 30ms cpython 3.11.1

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 2406ms 1.8ms 9.4MB 2360ms 30ms cpython 3.11.1
python 4.py 2409ms 0.6ms 9.1MB 2380ms 10ms pyston 3.8.12
python 4.py 2424ms 38ms 125.1MB 2353ms 57ms pypy 3.9.15

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 4.py 576ms 1.8ms 9.2MB 560ms 0ms cpython 3.11.1
python 4.py 576ms 3.1ms 8.8MB 560ms 0ms pyston 3.8.12
python 4.py 609ms 2.8ms 77.3MB 573ms 17ms pypy 3.9.15

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 3287ms 4.1ms 274.6MB 3157ms 110ms pypy 3.9.15
python 1.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 456ms 0.2ms 95.6MB 410ms 30ms pypy 3.9.15
python 1.py 765ms 2.0ms 30.5MB 727ms 20ms pyston 3.8.12
python 1.py 821ms 6.5ms 32.0MB 780ms 23ms cpython 3.11.1

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 4418ms 4.6ms 8.5MB 4403ms 0ms pyston 3.8.12
python 1.py 4739ms 16ms 8.4MB 4727ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.9.15

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 1119ms 1.2ms 8.4MB 1110ms 0ms pyston 3.8.12
python 1.py 1188ms 4.6ms 8.4MB 1170ms 3ms cpython 3.11.1
python 1.py 1473ms 4.5ms 74.7MB 1440ms 13ms pypy 3.9.15

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
perl 4.pl timeout 0.0ms 0.0MB 0ms 0ms perl 5.36.0
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.9.15
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
perl 4.pl timeout 0.0ms 0.0MB 0ms 0ms perl 5.36.0
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pypy 3.9.15
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 8-m.py 3747ms 75ms 103.8MB 6470ms 403ms pypy 3.9.15
perl 4-m.pl 4791ms 13ms 8.4MB 9343ms 3ms perl 5.36.0
python 8.py timeout 0.0ms 0.0MB 0ms 0ms cpython 3.11.1
python 8.py timeout 0.0ms 0.0MB 0ms 0ms pyston 3.8.12