lua-users home
lua-l archive

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


On Tue, Oct 28, 2014 at 5:00 PM, Enrico Colombini <erix@erix.it> wrote:
> I mentioned it about plain Lua (I have no experience with LuaJIT). I should
> have qualified it with a lot of "it depends...", starting with "it depends
> on how your interface is built".


many, many (most?) bytecode interpreters and emulators have this
'switching cost', where doing small operations in the "faster"
language might be slower than doing them in the "slower" language.

in my own microbenchmarks, long time ago (might be Lua 5.0, maybe
5.1), I found a few thumb rules: (of the top of my head)

- plain table get/set operations (without metatables) take roughly the
same time as a "nop" function call.  let's cal that time unit "f"

- allocating an empty table is roughly 3 f

- a 'set' operation that is handled by a __newindex function in Lua is
around 5-7f

- a nop C function call is around 5 f, but can be anywhere 3f and 6f

-- 
Javier