Lua VS Java benchmarks

Current benchmark data was generated on Wed Jan 22 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
java 2.java 467ms 1.5ms 646.0MB 567ms 97ms openjdk 23
java 2-m.java 468ms 12ms 645.0MB 687ms 90ms graal/jvm 17.0.8
java 2.java 498ms 2.1ms 572.9MB 563ms 113ms openjdk 21
java 2.java 1170ms 8.1ms 1044.5MB 570ms 760ms openjdk/zgc 21
lua 1.lua 3542ms 27ms 172.9MB 3407ms 117ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 104.9MB 4943ms 40ms lua 5.4.7

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2.java 126ms 6.8ms 96.2MB 147ms 40ms openjdk 23
java 2.java 127ms 1.9ms 168.9MB 160ms 23ms openjdk 21
java 2-m.java 150ms 3.7ms 231.2MB 210ms 67ms graal/jvm 17.0.8
lua 1.lua 291ms 1.8ms 15.8MB 267ms 3ms luajit 2.1.0-beta3
java 2.java 307ms 4.8ms 241.9MB 163ms 197ms openjdk/zgc 21
lua 1.lua 819ms 1.8ms 16.9MB 803ms 7ms 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.1ms 2.4MB 0ms 0ms luajit 2.1.0-beta3
lua 1.lua 1.8ms 0.4ms 2.1MB 0ms 0ms lua 5.4.7
java 1.java 64ms 1.6ms 54.9MB 66ms 18ms graal/jvm 17.0.8
java 1.java 71ms 6.1ms 43.9MB 80ms 16ms openjdk 21
java 1.java 72ms 6.3ms 44.7MB 70ms 20ms openjdk 23
java 1.java 186ms 4.8ms 44.6MB 90ms 126ms openjdk/zgc 21

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 397ms 2.9ms 630.4MB 593ms 97ms graal/jvm 17.0.8
java 1.java 401ms 1.0ms 537.3MB 483ms 103ms openjdk 23
java 1.java 401ms 4.9ms 679.9MB 467ms 90ms openjdk 21
java 1.java 1072ms 7.5ms 966.2MB 473ms 723ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 107.5MB 4940ms 47ms lua 5.4.7
lua 1.lua timeout 0.0ms 149.3MB 4933ms 47ms 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 164ms 3.1ms 207.5MB 237ms 40ms openjdk 21
java 1-m.java 164ms 2.2ms 160.1MB 243ms 37ms openjdk 23
java 1-m.java 207ms 1.6ms 255.6MB 343ms 57ms graal/jvm 17.0.8
java 1.java 432ms 23ms 343.8MB 200ms 307ms openjdk/zgc 21
lua 1.lua 1152ms 5.2ms 31.1MB 1120ms 17ms luajit 2.1.0-beta3
lua 1.lua 2299ms 31ms 28.6MB 2263ms 20ms lua 5.4.7

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 441ms 1.3ms 45.2MB 483ms 17ms openjdk 21
java 1.java 445ms 3.9ms 48.2MB 477ms 23ms openjdk 23
java 1.java 445ms 1.7ms 87.1MB 467ms 30ms graal/jvm 17.0.8
java 1.java 565ms 2.0ms 44.6MB 497ms 127ms openjdk/zgc 21
lua 4.lua 725ms 27ms 2.3MB 717ms 0ms luajit 2.1.0-beta3
java 2.java 1252ms 33ms 588.1MB 1390ms 83ms openjdk 21
java 2.java 1255ms 8.3ms 753.6MB 1367ms 107ms openjdk 23
java 2.java 3285ms 56ms 2475.9MB 1647ms 1840ms openjdk/zgc 21
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
lua 4.lua 74ms 1.2ms 2.3MB 67ms 0ms luajit 2.1.0-beta3
java 1.java 118ms 1.2ms 45.1MB 153ms 20ms openjdk 21
java 1.java 123ms 1.7ms 47.9MB 153ms 20ms openjdk 23
java 1.java 123ms 6.2ms 87.3MB 157ms 27ms graal/jvm 17.0.8
java 1.java 237ms 4.3ms 44.7MB 157ms 137ms openjdk/zgc 21
java 2-m.java 299ms 2.8ms 344.9MB 437ms 53ms openjdk 21
java 2-m.java 311ms 5.4ms 346.3MB 443ms 70ms openjdk 23
java 2.java 689ms 16ms 525.9MB 463ms 403ms openjdk/zgc 21
lua 4.lua 1103ms 17ms 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
java 2-m.java 1963ms 2.5ms 47.3MB 7453ms 20ms openjdk 21
java 2-m.java 1965ms 7.5ms 48.6MB 7467ms 17ms openjdk 23
java 2-m.java 2080ms 2.7ms 45.3MB 7453ms 143ms openjdk/zgc 21
java 2-m.java 2480ms 17ms 98.9MB 8800ms 40ms graal/jvm 17.0.8
lua 1.lua 4060ms 12ms 2.5MB 4047ms 0ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 2.5MB 4987ms 0ms lua 5.4.7

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 592ms 8.0ms 47.7MB 2083ms 13ms openjdk 21
java 2-m.java 592ms 6.7ms 48.8MB 2033ms 30ms openjdk 23
java 2-m.java 712ms 1.7ms 45.3MB 2087ms 133ms openjdk/zgc 21
java 2-m.java 739ms 6.2ms 98.0MB 2493ms 37ms graal/jvm 17.0.8
lua 1.lua 1017ms 2.5ms 2.4MB 1010ms 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
java 2-m.java 246ms 3.6ms 48.5MB 717ms 20ms openjdk 23
java 2-m.java 247ms 13ms 47.4MB 710ms 23ms openjdk 21
lua 1.lua 257ms 0.2ms 2.3MB 247ms 0ms luajit 2.1.0-beta3
java 2-m.java 285ms 13ms 96.7MB 827ms 40ms graal/jvm 17.0.8
java 2-m.java 355ms 6.7ms 47.3MB 680ms 137ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 2.0MB 4987ms 0ms lua 5.4.7