lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 18.07.2013 11:41 schröbte Philippe Lhoste:
On 15/07/2013 19:24, Roberto Ierusalimschy wrote:

http://raid6.com.au/~onlyjob/posts/arena/

This test is ridiculous. Whoever wrote the code does not know how
to program in Lua (or in Java or in Javascript).

Pointless benchmarks (no real world code) are pointless.


I, for one, learned a few interesting things because of this micro benchmark: One can improve Lua's runtime for this particular test from x30 to less than x2 compared to Perl by replacing string.gsub with pcre.gsub[1] and precompiling the regular expression `efgh` before the loop (which btw. is what Perl does as well). Apparently, interpreting even simple Lua patterns in a loop is costly compared to a compiled regular expression (which is of course what Malma's tests[2] already suggested).

  [1]: http://luarocks.org/repositories/rocks/#lrexlib-pcre
  [2]: http://permalink.gmane.org/gmane.comp.lang.lua.general/101253

Also, Lua 5.2 is 5-10% faster than 5.1 in this pathological case, but without any gsubs Lua 5.2 is 50+% slower than 5.1 (I had assumed that 5.2 had an advantage because of not hashing long strings). LuaJIT 2 doesn't help much here; it is slower than both PUC-Luas if using pcre.gsub, and faster than 5.2 (but not 5.1) without any gsubs. I don't know if this behavior could also occur in sensible Lua code ...

Philipp