Lua VS Python benchmarks

Current benchmark data was generated on Sun Jan 29 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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 1514ms 15ms 271.7MB 1403ms 93ms pypy 3.9.16
lua 1.lua timeout 0.0ms 119.6MB 4940ms 43ms lua 5.4.4
lua 1.lua timeout 0.0ms 180.4MB 4920ms 60ms luajit 2.1.0-beta3
python 1.py timeout 0.0ms 40.8MB 4970ms 10ms cpython 3.11.1
python 1.py timeout 0.0ms 40.3MB 4897ms 80ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 123ms 15ms 80.6MB 87ms 13ms pypy 3.9.16
lua 1.lua 409ms 5.4ms 25.0MB 387ms 3ms luajit 2.1.0-beta3
python 1.py 604ms 3.0ms 11.9MB 580ms 10ms pyston 3.8.12
python 1.py 976ms 8.7ms 12.4MB 960ms 0ms cpython 3.11.1
lua 1.lua 1054ms 8.6ms 17.4MB 1037ms 3ms lua 5.4.4

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1.9ms 0.5ms 2.5MB 0ms 0ms luajit 2.1.0-beta3
lua 1.lua 2.4ms 0.9ms 1.5MB 0ms 0ms lua 5.4.4
python 1.py 13ms 0.5ms 8.5MB 10ms 0ms cpython 3.11.1
python 1.py 14ms 0.7ms 7.3MB 10ms 0ms pyston 3.8.12
python 1.py 30ms 0.8ms 52.1MB 14ms 6ms pypy 3.9.16

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 2251ms 26ms 292.0MB 2047ms 183ms pypy 3.9.16
lua 1.lua timeout 0.0ms 159.2MB 4923ms 57ms lua 5.4.4
lua 1.lua timeout 0.0ms 180.9MB 4927ms 53ms luajit 2.1.0-beta3
python 1.py timeout 0.0ms 93.1MB 4967ms 13ms cpython 3.11.1
python 1.py timeout 0.0ms 130.3MB 4933ms 50ms pyston 3.8.12

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
python 1.py 317ms 1.6ms 138.4MB 273ms 27ms pypy 3.9.16
lua 1.lua 1630ms 18ms 35.4MB 1603ms 10ms luajit 2.1.0-beta3
lua 1.lua 2785ms 38ms 41.6MB 2753ms 10ms lua 5.4.4
python 1.py 4438ms 27ms 37.1MB 4410ms 10ms cpython 3.11.1
python 1.py timeout 0.0ms 48.9MB 4947ms 33ms pyston 3.8.12

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 4.lua 1104ms 10ms 1.5MB 1093ms 0ms luajit 2.1.0-beta3
python 2.py 1901ms 13ms 77.5MB 1870ms 13ms pypy 3.9.16
python 1.py 3515ms 41ms 76.6MB 3483ms 13ms pypy 3.9.16
lua 4.lua timeout 0.0ms 1.5MB 4990ms 0ms lua 5.4.4
python 1.py timeout 0.0ms 8.5MB 4987ms 0ms cpython 3.11.1
python 2.py timeout 0.0ms 8.6MB 4980ms 0ms cpython 3.11.1
python 1.py timeout 0.0ms 8.3MB 4987ms 0ms pyston 3.8.12
python 2.py timeout 0.0ms 8.0MB 4987ms 0ms pyston 3.8.12

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 4.lua 114ms 1.8ms 2.3MB 100ms 0ms luajit 2.1.0-beta3
python 2.py 243ms 1.5ms 77.1MB 220ms 7ms pypy 3.9.16
python 1.py 392ms 1.7ms 76.5MB 370ms 10ms pypy 3.9.16
python 1.py 1193ms 2.2ms 8.3MB 1173ms 0ms pyston 3.8.12
lua 4.lua 1204ms 27ms 1.4MB 1190ms 0ms lua 5.4.4
python 2.py 1646ms 27ms 7.9MB 1630ms 0ms pyston 3.8.12
python 2.py 3484ms 156ms 8.6MB 3473ms 0ms cpython 3.11.1
python 1.py 3541ms 305ms 8.5MB 3527ms 0ms cpython 3.11.1

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua timeout 0.0ms 2.3MB 4990ms 0ms lua 5.4.4
lua 1.lua timeout 0.0ms 2.6MB 4990ms 0ms luajit 2.1.0-beta3
python 8.py timeout 0.0ms 16.3MB 60ms 3ms cpython 3.11.1
python 8.py timeout 0.0ms 104.5MB 650ms 90ms pypy 3.9.16
python 8.py timeout 0.0ms 17.6MB 67ms 13ms pyston 3.8.12

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1561ms 0.9ms 2.5MB 1550ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.1MB 4990ms 0ms lua 5.4.4
python 8.py timeout 0.0ms 16.1MB 113ms 17ms cpython 3.11.1
python 8.py timeout 0.0ms 115.0MB 1113ms 200ms pypy 3.9.16
python 8.py timeout 0.0ms 17.5MB 167ms 30ms pyston 3.8.12

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 391ms 0.7ms 1.5MB 380ms 0ms luajit 2.1.0-beta3
python 8-m.py 3099ms 18ms 105.8MB 5327ms 327ms pypy 3.9.16
lua 1.lua timeout 0.0ms 1.4MB 4990ms 0ms lua 5.4.4
python 8.py timeout 0.0ms 15.8MB 257ms 23ms cpython 3.11.1
python 8.py timeout 0.0ms 17.1MB 353ms 47ms pyston 3.8.12

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 555ms 1.7ms 5.1MB 540ms 0ms luajit 2.1.0-beta3
python 1.py 1017ms 21ms 193.8MB 943ms 50ms pypy 3.9.16
python 1.py timeout 0.0ms 20.1MB 4980ms 7ms cpython 3.11.1
python 1.py timeout 0.0ms 17.1MB 4983ms 3ms pyston 3.8.12

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 39ms 1.0ms 3.1MB 30ms 0ms luajit 2.1.0-beta3
python 1.py 259ms 5.5ms 93.1MB 227ms 20ms pypy 3.9.16
python 1.py 820ms 6.1ms 20.0MB 800ms 3ms cpython 3.11.1
python 1.py 928ms 0.8ms 16.9MB 907ms 3ms pyston 3.8.12