Lua VS Java benchmarks

Current benchmark data was generated on Thu Feb 01 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
java 2.java 450ms 3.2ms 574.3MB 543ms 87ms openjdk 21
java 2-m.java 462ms 4.6ms 646.8MB 650ms 110ms graal/jvm 17.0.8
java 2.java 462ms 4.8ms 588.2MB 563ms 97ms openjdk 23
java 2.java 1178ms 0.9ms 1055.6MB 607ms 733ms openjdk/zgc 21
lua 1.lua 3568ms 87ms 172.9MB 3433ms 120ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 105.0MB 4950ms 40ms lua 5.4.6

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2.java 123ms 1.1ms 166.9MB 147ms 37ms openjdk 21
java 2-m.java 125ms 1.5ms 163.2MB 157ms 33ms openjdk 23
java 2-m.java 168ms 15ms 230.2MB 220ms 70ms graal/jvm 17.0.8
lua 1.lua 290ms 1.7ms 15.6MB 270ms 7ms luajit 2.1.0-beta3
java 2.java 314ms 1.3ms 241.4MB 153ms 213ms openjdk/zgc 21
lua 1.lua 855ms 12ms 17.0MB 840ms 3ms lua 5.4.6

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 1.lua 1.5ms 0.1ms 2.1MB 0ms 0ms lua 5.4.6
lua 1.lua 1.5ms 0.1ms 2.4MB 0ms 0ms luajit 2.1.0-beta3
java 1.java 66ms 3.1ms 54.7MB 64ms 24ms graal/jvm 17.0.8
java 1.java 73ms 1.9ms 43.8MB 74ms 14ms openjdk 21
java 1.java 73ms 2.7ms 43.9MB 80ms 14ms openjdk 23
java 1.java 189ms 6.4ms 42.6MB 84ms 132ms openjdk/zgc 21

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 399ms 1.6ms 680.1MB 480ms 80ms openjdk 21
java 1.java 400ms 2.6ms 658.4MB 477ms 80ms openjdk 23
java 1-m.java 411ms 5.6ms 638.2MB 593ms 120ms graal/jvm 17.0.8
java 1.java 1027ms 7.4ms 941.0MB 473ms 707ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 107.4MB 4950ms 40ms lua 5.4.6
lua 1.lua timeout 0.0ms 149.3MB 4937ms 53ms luajit 2.1.0-beta3

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 160ms 2.0ms 198.3MB 237ms 33ms openjdk 23
java 1-m.java 164ms 2.2ms 206.7MB 243ms 37ms openjdk 21
java 1-m.java 251ms 4.7ms 257.4MB 403ms 73ms graal/jvm 17.0.8
java 1.java 430ms 21ms 343.8MB 227ms 277ms openjdk/zgc 21
lua 1.lua 1196ms 6.5ms 31.3MB 1160ms 20ms luajit 2.1.0-beta3
lua 1.lua 2323ms 26ms 28.8MB 2303ms 3ms lua 5.4.6

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 443ms 1.2ms 47.6MB 487ms 13ms openjdk 23
java 1.java 444ms 1.9ms 45.4MB 477ms 20ms openjdk 21
java 1.java 455ms 6.6ms 86.8MB 483ms 30ms graal/jvm 17.0.8
java 1.java 559ms 4.6ms 46.7MB 480ms 133ms openjdk/zgc 21
lua 4.lua 707ms 1.1ms 2.4MB 697ms 0ms luajit 2.1.0-beta3
java 2.java 1234ms 5.9ms 597.7MB 1363ms 77ms openjdk 23
java 2.java 1238ms 9.8ms 647.8MB 1373ms 80ms openjdk 21
java 2.java 3177ms 56ms 2367.4MB 1670ms 1723ms openjdk/zgc 21
lua 4.lua timeout 0.0ms 2.3MB 4990ms 0ms lua 5.4.6

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 4.lua 76ms 2.8ms 2.4MB 63ms 0ms luajit 2.1.0-beta3
java 1.java 119ms 1.1ms 45.5MB 147ms 23ms openjdk 21
java 1.java 120ms 0.2ms 47.8MB 153ms 20ms openjdk 23
java 1.java 126ms 5.3ms 87.5MB 157ms 27ms graal/jvm 17.0.8
java 1.java 243ms 2.9ms 46.7MB 163ms 140ms openjdk/zgc 21
java 2-m.java 295ms 2.6ms 352.8MB 433ms 50ms openjdk 23
java 2-m.java 298ms 4.2ms 362.9MB 443ms 50ms openjdk 21
java 2.java 681ms 8.7ms 528.1MB 440ms 427ms openjdk/zgc 21
lua 4.lua 1138ms 22ms 2.3MB 1127ms 0ms lua 5.4.6

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 1956ms 9.0ms 48.0MB 7453ms 37ms openjdk 23
java 2-m.java 1957ms 12ms 47.8MB 7463ms 27ms openjdk 21
java 2-m.java 2081ms 13ms 45.6MB 7440ms 140ms openjdk/zgc 21
java 2-m.java 2462ms 20ms 94.8MB 8777ms 47ms graal/jvm 17.0.8
lua 1.lua 4049ms 5.8ms 2.5MB 4037ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.4MB 4990ms 0ms lua 5.4.6

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 583ms 3.4ms 47.7MB 2050ms 20ms openjdk 21
java 2-m.java 586ms 3.4ms 47.9MB 2070ms 20ms openjdk 23
java 2-m.java 713ms 3.2ms 45.6MB 2100ms 133ms openjdk/zgc 21
java 2-m.java 744ms 11ms 100.2MB 2513ms 37ms graal/jvm 17.0.8
lua 1.lua 1015ms 1.6ms 2.4MB 1003ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.3MB 4990ms 0ms lua 5.4.6

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 233ms 0.9ms 47.6MB 667ms 20ms openjdk 21
java 2-m.java 243ms 5.5ms 47.9MB 727ms 23ms openjdk 23
lua 1.lua 259ms 2.7ms 2.3MB 250ms 0ms luajit 2.1.0-beta3
java 2-m.java 277ms 8.5ms 98.5MB 783ms 43ms graal/jvm 17.0.8
java 2-m.java 372ms 13ms 45.5MB 740ms 133ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 2.0MB 4993ms 0ms lua 5.4.6