Lua VS C++ 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.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua timeout 0.0ms 119.5MB 4903ms 70ms lua 5.4.4
lua 1.lua timeout 0.0ms 174.6MB 4897ms 83ms luajit 2.1.0-beta3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 584ms 53ms 24.6MB 553ms 10ms luajit 2.1.0-beta3
lua 1.lua 1408ms 8.5ms 17.4MB 1387ms 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 2.4ms 0.8ms 2.2MB 0ms 0ms luajit 2.1.0-beta3
cpp 1.cpp 2.4ms 0.7ms 1.3MB 0ms 0ms g++ 12.2.0
cpp 1.cpp 2.4ms 0.7ms 1.4MB 0ms 0ms clang++ 14.0.0
lua 1.lua 2.4ms 1.0ms 1.4MB 0ms 0ms lua 5.4.4

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua timeout 0.0ms 159.1MB 4913ms 67ms lua 5.4.4
lua 1.lua timeout 0.0ms 180.9MB 4870ms 107ms luajit 2.1.0-beta3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 2162ms 57ms 38.5MB 2130ms 13ms luajit 2.1.0-beta3
lua 1.lua 3623ms 55ms 41.6MB 3593ms 13ms lua 5.4.4

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 218ms 1.5ms 1.4MB 203ms 0ms g++ 12.2.0
cpp 0-i.cpp 253ms 4.3ms 1.4MB 243ms 0ms clang++ 14.0.0
cpp 1.cpp 413ms 9.0ms 1.4MB 400ms 0ms g++ 12.2.0
cpp 1.cpp 417ms 9.1ms 1.5MB 407ms 0ms clang++ 14.0.0
lua 4.lua 1337ms 28ms 1.5MB 1320ms 0ms luajit 2.1.0-beta3
lua 4.lua timeout 0.0ms 1.5MB 4990ms 0ms lua 5.4.4

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 25ms 0.3ms 1.3MB 13ms 0ms g++ 12.2.0
cpp 0-i.cpp 28ms 0.2ms 1.4MB 20ms 0ms clang++ 14.0.0
cpp 1.cpp 45ms 0.3ms 1.4MB 40ms 0ms clang++ 14.0.0
cpp 1.cpp 46ms 1.9ms 1.3MB 40ms 0ms g++ 12.2.0
lua 4.lua 138ms 1.4ms 1.5MB 123ms 0ms luajit 2.1.0-beta3
lua 4.lua 1886ms 102ms 1.4MB 1873ms 0ms lua 5.4.4

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 1061ms 4.5ms 3.7MB 2067ms 3ms clang++ 14.0.0
cpp 7-m.cpp 1065ms 5.3ms 3.3MB 2080ms 0ms clang++ 14.0.0
cpp 8-m.cpp 1071ms 5.9ms 1.3MB 2087ms 0ms g++ 12.2.0
cpp 7-m.cpp 1071ms 11ms 1.4MB 2073ms 0ms g++ 12.2.0
cpp 6-im.cpp 2187ms 29ms 1.3MB 4277ms 0ms g++ 12.2.0
cpp 6-im.cpp 2209ms 24ms 3.4MB 4327ms 3ms clang++ 14.0.0
lua 1.lua timeout 0.0ms 2.2MB 4977ms 3ms lua 5.4.4
lua 1.lua timeout 0.0ms 2.5MB 4987ms 0ms luajit 2.1.0-beta3

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 7-m.cpp 271ms 2.1ms 1.3MB 510ms 0ms g++ 12.2.0
cpp 7-m.cpp 278ms 3.3ms 3.3MB 517ms 0ms clang++ 14.0.0
cpp 8-m.cpp 281ms 2.7ms 1.3MB 523ms 0ms g++ 12.2.0
cpp 8-m.cpp 283ms 8.5ms 3.5MB 527ms 0ms clang++ 14.0.0
cpp 6-im.cpp 546ms 13ms 1.3MB 1053ms 0ms g++ 12.2.0
cpp 6-im.cpp 560ms 0.6ms 3.3MB 1077ms 3ms clang++ 14.0.0
lua 1.lua 1702ms 29ms 2.5MB 1687ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.3MB 4987ms 0ms lua 5.4.4

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 7-m.cpp 73ms 1.9ms 1.4MB 120ms 0ms g++ 12.2.0
cpp 8-m.cpp 77ms 0.2ms 3.3MB 130ms 0ms clang++ 14.0.0
cpp 8-m.cpp 78ms 1.5ms 1.3MB 130ms 0ms g++ 12.2.0
cpp 7-m.cpp 79ms 2.5ms 3.5MB 130ms 0ms clang++ 14.0.0
cpp 6-im.cpp 151ms 0.9ms 1.3MB 273ms 0ms g++ 12.2.0
cpp 6-im.cpp 152ms 0.4ms 3.7MB 273ms 0ms clang++ 14.0.0
lua 1.lua 434ms 2.7ms 1.5MB 423ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 1.5MB 4990ms 0ms lua 5.4.4