C VS Python benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

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

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 2.4ms 0.7ms 1.4MB 0ms 0ms clang 14.0.0
c 1.c 2.6ms 0.8ms 1.3MB 0ms 0ms gcc 12.2.0
c 1.c 3.4ms 2.1ms 1.0MB 0ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
python 1.py 15ms 0.7ms 7.3MB 10ms 0ms pyston 3.8.12
python 1.py 16ms 1.3ms 8.5MB 10ms 0ms cpython 3.11.2
python 1.py 39ms 0.9ms 52.8MB 12ms 12ms pypy 3.9.16

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1-m.c 292ms 5.8ms 23.5MB 480ms 13ms gcc 12.2.0
c 1-m.c 581ms 11ms 20.5MB 977ms 23ms clang 14.0.0
python 3-m.py 4923ms 24ms 209.9MB 8630ms 467ms pypy 3.9.16
python 3.py timeout 0.0ms 35.1MB 100ms 27ms cpython 3.11.2
python 3.py timeout 0.0ms 34.2MB 80ms 27ms pyston 3.8.12

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 43ms 1.2ms 13.6MB 53ms 7ms gcc 12.2.0
c 1-m.c 71ms 3.2ms 9.7MB 113ms 0ms clang 14.0.0
python 3-m.py 686ms 12ms 86.1MB 1000ms 143ms pypy 3.9.16
python 3-m.py 737ms 14ms 17.6MB 1283ms 47ms pyston 3.8.12
python 3-m.py 1024ms 9.7ms 16.9MB 1843ms 43ms cpython 3.11.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 331ms 4.8ms 1.2MB 320ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 8-i.c 398ms 5.5ms 1.3MB 387ms 0ms gcc 12.2.0
c 5.c 403ms 1.6ms 1.3MB 390ms 0ms gcc 12.2.0
c 5.c 422ms 5.1ms 1.4MB 410ms 0ms clang 14.0.0
c 8-i.c 423ms 7.5ms 1.4MB 410ms 0ms clang 14.0.0
c 5.c 426ms 3.6ms 1.0MB 413ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 433ms 1.0ms 1.2MB 420ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 467ms 4.0ms 1.4MB 453ms 0ms clang 14.0.0
c 2.c 592ms 1.5ms 1.3MB 580ms 0ms gcc 12.2.0
python 2.py 2414ms 33ms 71.4MB 2383ms 17ms pypy 3.9.16
python 1.py 4354ms 39ms 70.3MB 4317ms 17ms pypy 3.9.16
python 1.py timeout 0.0ms 8.4MB 4983ms 0ms cpython 3.11.2
python 2.py timeout 0.0ms 8.6MB 4987ms 0ms cpython 3.11.2
python 1.py timeout 0.0ms 8.4MB 4983ms 3ms pyston 3.8.12
python 2.py timeout 0.0ms 7.9MB 4973ms 7ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 8-i.c 37ms 1.3ms 1.3MB 27ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 8-i.c 43ms 1.7ms 1.3MB 30ms 0ms gcc 12.2.0
c 5.c 43ms 0.8ms 1.3MB 30ms 0ms gcc 12.2.0
c 5.c 45ms 1.0ms 1.4MB 37ms 0ms clang 14.0.0
c 8-i.c 45ms 0.2ms 1.4MB 30ms 0ms clang 14.0.0
c 2.c 47ms 0.6ms 1.2MB 40ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 51ms 2.5ms 1.4MB 40ms 0ms clang 14.0.0
c 5.c 53ms 4.0ms 1.0MB 43ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 2.c 63ms 0.8ms 1.3MB 50ms 0ms gcc 12.2.0
python 2.py 309ms 3.3ms 71.0MB 277ms 17ms pypy 3.9.16
python 1.py 499ms 4.8ms 70.3MB 460ms 20ms pypy 3.9.16
python 1.py 1397ms 19ms 8.3MB 1380ms 0ms pyston 3.8.12
python 2.py 1891ms 7.9ms 7.9MB 1873ms 3ms pyston 3.8.12
python 1.py 3917ms 146ms 8.4MB 3903ms 0ms cpython 3.11.2
python 2.py 4128ms 39ms 8.6MB 4107ms 0ms cpython 3.11.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 1081ms 39ms 40.2MB 1043ms 23ms zigcc 0.11.0-dev.1580+a5b34a61a
c 1.c 1125ms 33ms 41.0MB 1087ms 17ms gcc 12.2.0
c 1.c 1130ms 22ms 40.9MB 1090ms 27ms clang 14.0.0
python 1.py timeout 0.0ms 321.1MB 4883ms 97ms cpython 3.11.2
python 2.py timeout 0.0ms 633.7MB 4543ms 437ms cpython 3.11.2
python 1.py timeout 0.0ms 382.8MB 4817ms 160ms pypy 3.9.16
python 2.py timeout 0.0ms 984.6MB 4567ms 407ms pypy 3.9.16
python 1.py timeout 0.0ms 320.4MB 4907ms 73ms pyston 3.8.12
python 2.py timeout 0.0ms 633.0MB 4470ms 513ms pyston 3.8.12

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 1.c 128ms 0.8ms 11.0MB 117ms 0ms zigcc 0.11.0-dev.1580+a5b34a61a
c 1.c 143ms 6.8ms 11.7MB 127ms 0ms clang 14.0.0
c 1.c 146ms 0.9ms 11.7MB 130ms 0ms gcc 12.2.0
python 1.py 1274ms 13ms 207.0MB 1197ms 60ms pypy 3.9.16
python 2.py 1351ms 12ms 164.3MB 1267ms 73ms pyston 3.8.12
python 2.py 2045ms 5.7ms 164.8MB 1947ms 80ms cpython 3.11.2
python 2.py 2170ms 38ms 210.3MB 2020ms 130ms pypy 3.9.16
python 1.py 2641ms 32ms 86.0MB 2583ms 40ms pyston 3.8.12
python 1.py 4357ms 11ms 86.7MB 4297ms 40ms cpython 3.11.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 1534ms 9.7ms 1.3MB 2990ms 3ms gcc 12.2.0
c 6-im.c 1961ms 20ms 1.3MB 3820ms 0ms gcc 12.2.0
c 4-m.c 1986ms 14ms 5.2MB 3877ms 0ms clang 14.0.0
c 6-im.c 1990ms 12ms 3.2MB 3890ms 7ms clang 14.0.0
c 5-im.c 1998ms 19ms 1.3MB 3857ms 0ms gcc 12.2.0
c 3-m.c 2263ms 5.2ms 3.2MB 4437ms 0ms clang 14.0.0
c 3-m.c 2269ms 18ms 1.3MB 4430ms 0ms gcc 12.2.0
c 5-im.c 2451ms 11ms 3.3MB 4797ms 0ms clang 14.0.0
python 8.py timeout 0.0ms 16.5MB 60ms 17ms cpython 3.11.2
python 8.py timeout 0.0ms 98.9MB 643ms 93ms pypy 3.9.16
python 8.py timeout 0.0ms 17.5MB 57ms 20ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 397ms 1.4ms 1.3MB 750ms 0ms gcc 12.2.0
c 6-im.c 469ms 3.9ms 1.3MB 893ms 0ms gcc 12.2.0
c 6-im.c 499ms 7.3ms 3.3MB 957ms 0ms clang 14.0.0
c 4-m.c 505ms 1.7ms 3.1MB 963ms 0ms clang 14.0.0
c 5-im.c 516ms 3.1ms 1.3MB 970ms 3ms gcc 12.2.0
c 3-m.c 581ms 4.7ms 1.3MB 1117ms 0ms gcc 12.2.0
c 3-m.c 588ms 9.4ms 3.1MB 1127ms 0ms clang 14.0.0
c 5-im.c 629ms 5.3ms 3.2MB 1200ms 3ms clang 14.0.0
python 8.py timeout 0.0ms 14.3MB 133ms 20ms cpython 3.11.2
python 8.py timeout 0.0ms 103.4MB 1023ms 183ms pypy 3.9.16
python 8.py timeout 0.0ms 17.1MB 150ms 33ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
c 4-m.c 111ms 3.3ms 1.3MB 193ms 0ms gcc 12.2.0
c 6-im.c 127ms 1.0ms 1.3MB 223ms 0ms gcc 12.2.0
c 4-m.c 136ms 1.4ms 3.3MB 240ms 0ms clang 14.0.0
c 6-im.c 138ms 0.8ms 3.2MB 250ms 0ms clang 14.0.0
c 5-im.c 140ms 2.7ms 1.3MB 250ms 0ms gcc 12.2.0
c 3-m.c 158ms 1.8ms 3.5MB 283ms 0ms clang 14.0.0
c 3-m.c 162ms 8.8ms 1.3MB 287ms 0ms gcc 12.2.0
c 5-im.c 173ms 6.0ms 3.3MB 300ms 3ms clang 14.0.0
python 8-m.py 4367ms 34ms 102.1MB 7580ms 460ms pypy 3.9.16
python 8.py timeout 0.0ms 15.9MB 243ms 33ms cpython 3.11.2
python 8.py timeout 0.0ms 17.1MB 333ms 63ms pyston 3.8.12