This infographic measures the speed of Lua's virtual machine with the same script on each Lua version.
The script calls recursive factorial function with number 16 1000000 times. The benchmark was run on x64 Windows machine with 4 cores. All executables were 64-bit.
Used script:
- For Lua 1.0 and 1.1
- For Lua 2.1 (changed
=
to==
) - For Lua 2.2 (local declaration merged with assignation)
- For Lua 2.4 up to Lua 3.1 (local recursive function are no longer available)
- For Lua 3.2 (available again)
- For Lua 3.2.1 up to Lua 3.2.2 (removed again)
- For Lua 4.0 up to Lua 4.0.1 (for statement was introduced)
- For Lua 5.0 up to Lua 5.4.1 (recursive local/upvalued function available again)
The variety of version is meant to follow nature coding style in Lua. Example: repeat until
was used in Lua 1.0 until for statement was introduced in 4.0.
Benchmark uses Windows API for measuring the elapsed time. The result of the benchmark is a median value of 50 runs using recorder script.
Conclusion:
- Lua 5.4 beat the speed record after version 1.1. In comparison, latest LuaJIT runs this script for 85.4ms when JIT-compiled, and for 370.3ms when JIT is off. (Lua 5.4.1 runs for 490.8ms)
- Compiling time is pretty much stable for the entire Lua development.