lua-users home
lua-l archive

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



The following two blocks for code are identical except that one loop has
two table accesses in it. The one with tables runs at less then half the
speed.

local x, y, i = 0, 3, 0
while i < 500000 do
    x = i * y
    i = i + 1
end

local t = { x = 0, y = 3 }
local i = 0
while i < 500000 do
    t.x = i * t.y
    i = i + 1
end

Hmmm... interesting. Are you using Lua 5? On what platform?

I've just benchmarked the same code on my Lua 4 system under Windows. The second loop performs definitely better than half the speed here. It needs approx. 1.6x the time needed for the 1st loop.

Ashwin.
--
no signature is a signature