As there's already a benchmark comparing QuickJS and the V8 JIT, this also let's us reason how Lua would fare in comparison to a heavily tuned JIT.
We compare the performance for "fannkuch redux", a well-established benchmark program which originally featured on debian's shootout game, which was later redacted because it was not seen as "politically correct" to compare speed. Implementors of slow languages felt offended, and successfully lobbied to take it down.
requires a small modication from
scriptArgs for quickjs.
Since the js version is a transliteration of the lua code, this test couldn't be any fairer.
Tested versions are
QuickJS version 2020-11-08 and
Lua 5.3.6 Copyright (C) 1994-2020 Lua.org, PUC-Rio,
running on an AMD Ryzen 7 3700X 8-Core Processor, but on only one core.
Results for QuickJS and Lua compiled with -Os:
$ time qjs fannkuch.js 11 556355 Pfannkuchen(11) = 51 real 0m41.560s user 0m41.558s sys 0m0.002s $ time lua5.3 fannkuch.lua 11 556355 Pfannkuchen(11) = 51 real 0m40.585s user 0m40.584s sys 0m0.000s
Results for QuickJS and Lua compiled with -O3 each:
$ time qjs fannkuch.js 11 556355 Pfannkuchen(11) = 51 real 0m40.950s user 0m40.946s sys 0m0.000s $ time lua5.3 fannkuch.lua 11 556355 Pfannkuchen(11) = 51 real 0m35.973s user 0m35.973s sys 0m0.000s
When optimized for size, Lua and QuickJS perform almost identically, whereas Lua is slightly
faster (about 15%) when compiled for speed. That's a quite impressive result for QuickJS, as
Lua is known to be one of the fastest non-jitted programming languages out there and has
been around for a while, whereas QuickJS is the new kid on the block.
QuickJS does spend a lot more time building though: using
make -j 16 it takes 16 seconds,
Lua compiles in one second.
Of course this little benchmark tests only a small subset of the functionality of those language interpreters, and is by no means conclusive, but IMO it's sufficient to give a good picture of the ballpark they're in.
An interesting addition would be to compare against the performance of the Dino language which is the fastest scripting language I'm aware of (with JIT turned off).