Lua VS Zig benchmarks

Current benchmark data was generated on Thu Dec 26 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
zig 1.zig 1779ms 35ms 49.1MB 1750ms 17ms zig 0.13.0
lua 1.lua 3541ms 108ms 172.8MB 3390ms 133ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 104.9MB 4953ms 30ms lua 5.4.7

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 150ms 2.8ms 7.1MB 137ms 0ms zig 0.13.0
lua 1.lua 289ms 1.3ms 15.9MB 270ms 7ms luajit 2.1.0-beta3
lua 1.lua 812ms 8.1ms 16.9MB 797ms 0ms lua 5.4.7

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 1.1ms 0.0ms 1.3MB 0ms 0ms zig 0.13.0
lua 1.lua 1.5ms 0.2ms 2.4MB 0ms 0ms luajit 2.1.0-beta3
lua 1.lua 1.6ms 0.4ms 2.1MB 0ms 0ms lua 5.4.7

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 838ms 8.4ms 41.1MB 810ms 10ms zig 0.13.0
lua 1.lua timeout 0.0ms 107.4MB 4943ms 40ms lua 5.4.7
lua 1.lua timeout 0.0ms 149.3MB 4943ms 40ms luajit 2.1.0-beta3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 170ms 1.1ms 11.1MB 157ms 0ms zig 0.13.0
lua 1.lua 1144ms 17ms 31.0MB 1107ms 20ms luajit 2.1.0-beta3
lua 1.lua 2216ms 8.1ms 28.6MB 2197ms 0ms lua 5.4.7

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 273ms 0.2ms 1.1MB 267ms 0ms zig 0.13.0
zig 1.zig 314ms 1.8ms 1.3MB 303ms 0ms zig 0.13.0
lua 4.lua 714ms 4.3ms 2.3MB 707ms 0ms luajit 2.1.0-beta3
lua 4.lua timeout 0.0ms 2.3MB 4990ms 0ms lua 5.4.7

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 29ms 0.1ms 1.1MB 20ms 0ms zig 0.13.0
zig 1.zig 34ms 0.4ms 1.3MB 20ms 0ms zig 0.13.0
lua 4.lua 74ms 0.7ms 2.3MB 60ms 0ms luajit 2.1.0-beta3
lua 4.lua 1103ms 45ms 2.3MB 1090ms 0ms lua 5.4.7

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 478ms 4.2ms 3.8MB 1560ms 13ms zig 0.13.0
zig 2.zig 918ms 6.5ms 1.5MB 907ms 0ms zig 0.13.0
zig 1.zig 3680ms 7.2ms 1.5MB 3670ms 0ms zig 0.13.0
lua 1.lua 4056ms 4.7ms 2.5MB 4043ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.4MB 4987ms 0ms lua 5.4.7

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 126ms 2.0ms 3.7MB 277ms 3ms zig 0.13.0
zig 2.zig 232ms 2.3ms 1.4MB 223ms 0ms zig 0.13.0
zig 1.zig 919ms 1.8ms 1.4MB 907ms 0ms zig 0.13.0
lua 1.lua 1020ms 5.9ms 2.4MB 1007ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.1MB 4990ms 0ms lua 5.4.7

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 39ms 1.1ms 3.7MB 33ms 0ms zig 0.13.0
zig 2.zig 60ms 0.6ms 1.4MB 50ms 0ms zig 0.13.0
zig 1.zig 233ms 1.3ms 1.4MB 220ms 0ms zig 0.13.0
lua 1.lua 260ms 0.9ms 2.3MB 250ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.1MB 4990ms 0ms lua 5.4.7