lua-users home
lua-l archive

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


On Wed, May 26, 2010 at 10:19 AM, M Joonas Pihlaja
<jpihlaja@cc.helsinki.fi> wrote:
> Thanks for posting this.  Clearly it's not a lot of code to carry
> around if you miss ipairs, and your version even has __ipairs support
> to boot.

Thanks, as well.  Here are some numbers for the hypothetical 'no
payload' case - yes, it's a microbenchmark, but at least it's
quantitative:

fake Lua: took   1.06 sec
lua 5.1: took    0.67 sec

So one does pay, but in real life there's a non-trivial loop payload.
For instance, if that payload was evaluating a sin function, then the
actual loop slow-down is only 30%

Naturally, a for-loop is very good at this (includes the 'local val = t[i]')

for loop: took    0.28 sec

And here's a hybrid, using a little bit of C for the ipairs helper.

fake C: took    0.73 sec

steve d.