lua-users home
lua-l archive

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

I'm really sorry. I ran the tests again and got your results. I do not know what I did to get the first results (repeatedly). I removed the benchmarks.

From your comments, I understand that I should use the metatable approach since LuaJit can do more optimizations on them and memory usage is lower, is this correct ?


On Fri, Nov 26, 2010 at 10:02 PM, Mike Pall <> wrote:
Gaspard Bucher wrote:
> > Oh well ... you've mixed up the results: the metatable variant is
> > definitely faster with LuaJIT.
> The metatable variant takes 341ms to run with LuaJit when it takes 1319ms
> with Lua.

$ time luajit metatable.lua
connect mix1 --> mix2

$ time luajit closure.lua
connect mix1 --> mix2

Actually they take less than 10ms, but you can't see that with
'time', since this is below its timing accuracy.

> Is this not "faster" enough ?

Does it matter to you how fast a mostly empty loop runs? If not,
then you're not actually measuring what you want to measure.
Drawing any conclusions from the results is a bit daring then.

> If it turns the metatable into an empty loop, why does it take longer then
> the closure version ?

It doesn't. Run them again and you'll see.