Lua VS OCaml benchmarks

Current benchmark data was generated on Mon Mar 31 2025, 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
ocaml 1.ml 2992ms 15ms 157.1MB 2910ms 70ms ocaml 5.3.0
lua 1.lua 3623ms 23ms 173.0MB 3477ms 133ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 104.9MB 4953ms 33ms lua 5.4.7

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 219ms 1.1ms 19.2MB 203ms 0ms ocaml 5.3.0
lua 1.lua 292ms 3.1ms 15.9MB 267ms 10ms luajit 2.1.0-beta3
lua 1.lua 824ms 5.5ms 16.9MB 807ms 0ms lua 5.4.7

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1.5ms 0.2ms 2.3MB 0ms 0ms luajit 2.1.0-beta3
lua 1.lua 1.6ms 0.1ms 2.1MB 0ms 0ms lua 5.4.7
ocaml 1.ml 1.9ms 0.1ms 5.1MB 0ms 0ms ocaml 5.3.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 1092ms 5.1ms 70.2MB 1047ms 30ms ocaml 5.3.0
ocaml 2.ml 2145ms 35ms 91.7MB 2087ms 40ms ocaml 5.3.0
lua 1.lua timeout 0.0ms 107.4MB 4947ms 37ms lua 5.4.7
lua 1.lua timeout 0.0ms 149.4MB 4923ms 63ms luajit 2.1.0-beta3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 152ms 1.5ms 21.6MB 137ms 0ms ocaml 5.3.0
ocaml 2.ml 366ms 3.1ms 27.7MB 343ms 10ms ocaml 5.3.0
lua 1.lua 1392ms 85ms 31.1MB 1360ms 13ms luajit 2.1.0-beta3
lua 1.lua 2291ms 16ms 28.6MB 2270ms 10ms lua 5.4.7

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
ocaml 1.ml 373ms 2.2ms 5.2MB 360ms 0ms ocaml 5.3.0
lua 4.lua 713ms 1.8ms 2.3MB 703ms 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
ocaml 1.ml 42ms 0.9ms 5.2MB 30ms 0ms ocaml 5.3.0
lua 4.lua 75ms 1.1ms 2.4MB 70ms 0ms luajit 2.1.0-beta3
lua 4.lua 1112ms 26ms 2.3MB 1103ms 0ms lua 5.4.7

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 4068ms 9.8ms 2.5MB 4057ms 0ms luajit 2.1.0-beta3
ocaml 2.ml 4556ms 14ms 6.4MB 4543ms 0ms ocaml 5.3.0
lua 1.lua timeout 0.0ms 2.4MB 4990ms 0ms lua 5.4.7

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1021ms 2.2ms 2.4MB 1010ms 0ms luajit 2.1.0-beta3
ocaml 2.ml 1140ms 6.4ms 6.1MB 1130ms 0ms ocaml 5.3.0
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
lua 1.lua 261ms 2.8ms 2.3MB 250ms 0ms luajit 2.1.0-beta3
ocaml 2.ml 291ms 5.2ms 5.2MB 283ms 0ms ocaml 5.3.0
lua 1.lua timeout 0.0ms 2.0MB 4990ms 0ms lua 5.4.7