Lua VS Java benchmarks

Current benchmark data was generated on Tue Dec 31 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 428ms 6.0ms 574.2MB 503ms 83ms openjdk 21
java 2-m.java 448ms 5.4ms 648.6MB 620ms 120ms graal/jvm 17.0.8
java 2.java 451ms 8.7ms 650.1MB 557ms 87ms openjdk 23
java 2.java 1140ms 6.2ms 1085.8MB 540ms 753ms openjdk/zgc 21
lua 1.lua 3311ms 71ms 172.9MB 3173ms 127ms luajit 2.1.0-beta3
lua 1.lua timeout 0.0ms 104.9MB 4940ms 47ms lua 5.4.7

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 117ms 3.3ms 167.6MB 147ms 30ms openjdk 21
java 2.java 122ms 6.2ms 98.2MB 143ms 33ms openjdk 23
java 2-m.java 153ms 9.8ms 226.4MB 223ms 60ms graal/jvm 17.0.8
lua 1.lua 277ms 1.4ms 15.6MB 257ms 3ms luajit 2.1.0-beta3
java 2.java 289ms 1.8ms 241.5MB 147ms 187ms openjdk/zgc 21
lua 1.lua 757ms 1.9ms 17.0MB 743ms 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.0ms 2.4MB 0ms 0ms luajit 2.1.0-beta3
lua 1.lua 2.2ms 1.0ms 2.1MB 0ms 0ms lua 5.4.7
java 1.java 61ms 1.3ms 58.6MB 60ms 20ms graal/jvm 17.0.8
java 1.java 69ms 2.9ms 44.7MB 66ms 14ms openjdk 23
java 1.java 69ms 1.0ms 43.8MB 72ms 10ms openjdk 21
java 1.java 174ms 5.3ms 44.5MB 80ms 116ms openjdk/zgc 21

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 377ms 8.2ms 679.9MB 450ms 77ms openjdk 21
java 1.java 383ms 9.9ms 546.0MB 480ms 80ms openjdk 23
java 1-m.java 408ms 27ms 589.2MB 630ms 77ms graal/jvm 17.0.8
java 1.java 1004ms 16ms 1000.0MB 447ms 697ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 107.3MB 4950ms 37ms lua 5.4.7
lua 1.lua timeout 0.0ms 149.3MB 4937ms 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 153ms 0.5ms 206.4MB 210ms 50ms openjdk 21
java 1-m.java 154ms 0.8ms 158.8MB 213ms 47ms openjdk 23
java 1-m.java 210ms 8.6ms 260.7MB 360ms 47ms graal/jvm 17.0.8
java 1.java 386ms 10ms 343.0MB 210ms 247ms openjdk/zgc 21
lua 1.lua 1019ms 0.9ms 31.1MB 983ms 20ms luajit 2.1.0-beta3
lua 1.lua 2026ms 40ms 28.6MB 2003ms 3ms lua 5.4.7

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 417ms 2.4ms 45.2MB 450ms 13ms openjdk 21
java 1.java 420ms 6.1ms 48.2MB 450ms 20ms openjdk 23
java 1.java 429ms 7.0ms 85.0MB 457ms 27ms graal/jvm 17.0.8
java 1.java 530ms 6.4ms 46.5MB 450ms 130ms openjdk/zgc 21
lua 4.lua 677ms 3.8ms 2.3MB 670ms 0ms luajit 2.1.0-beta3
java 2.java 1166ms 4.4ms 571.8MB 1293ms 77ms openjdk 21
java 2.java 1187ms 9.7ms 717.8MB 1287ms 90ms openjdk 23
java 2.java 3101ms 57ms 2431.6MB 1560ms 1743ms openjdk/zgc 21
lua 4.lua timeout 0.0ms 2.3MB 4987ms 0ms lua 5.4.7

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
lua 4.lua 72ms 3.0ms 2.3MB 60ms 0ms luajit 2.1.0-beta3
java 1.java 111ms 2.5ms 45.2MB 137ms 20ms openjdk 21
java 1.java 112ms 0.7ms 87.3MB 130ms 30ms graal/jvm 17.0.8
java 1.java 114ms 1.2ms 48.5MB 140ms 20ms openjdk 23
java 1.java 230ms 5.1ms 46.5MB 150ms 133ms openjdk/zgc 21
java 2-m.java 289ms 6.3ms 348.4MB 407ms 70ms openjdk 23
java 2-m.java 293ms 18ms 355.0MB 440ms 30ms openjdk 21
java 2.java 658ms 2.3ms 536.9MB 437ms 403ms openjdk/zgc 21
lua 4.lua 1042ms 22ms 2.3MB 1033ms 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 1867ms 20ms 47.6MB 7143ms 20ms openjdk 21
java 2-m.java 1877ms 26ms 49.0MB 7130ms 20ms openjdk 23
java 2-m.java 1981ms 11ms 45.4MB 7137ms 137ms openjdk/zgc 21
java 2-m.java 2318ms 11ms 100.9MB 8233ms 47ms graal/jvm 17.0.8
lua 1.lua 3844ms 19ms 2.5MB 3830ms 0ms luajit 2.1.0-beta3
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
java 2-m.java 557ms 2.8ms 48.4MB 1953ms 27ms openjdk 23
java 2-m.java 558ms 2.6ms 47.5MB 1963ms 23ms openjdk 21
java 2-m.java 676ms 7.0ms 45.6MB 1957ms 140ms openjdk/zgc 21
java 2-m.java 688ms 5.7ms 98.9MB 2293ms 57ms graal/jvm 17.0.8
lua 1.lua 970ms 12ms 2.4MB 960ms 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 229ms 5.7ms 48.4MB 670ms 23ms openjdk 23
java 2-m.java 238ms 14ms 47.6MB 693ms 20ms openjdk 21
lua 1.lua 243ms 1.7ms 2.3MB 230ms 0ms luajit 2.1.0-beta3
java 2-m.java 281ms 23ms 101.8MB 823ms 40ms graal/jvm 17.0.8
java 2-m.java 346ms 3.4ms 47.1MB 667ms 133ms openjdk/zgc 21
lua 1.lua timeout 0.0ms 2.0MB 4990ms 0ms lua 5.4.7