lua-users home
lua-l archive

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


OK, I hit the send button to quickly... :-( I should have mentioned that I timed only the interation loops (of course), not the setup of the initial table. Then I realised that the test only uses an array (indexed by consecutive numbers) so I changed it like so:

 Lua 4.0.1 version:

     local t = {}
     for i = 1, 1e4 do t[tostring(i)] = i*i end

     for i = 1, 1e4 do
       for k, v in t do end
     end

 Lua 5.0.2 and 5.1-alpha version:

     local t = {}
     for i = 1, 1e4 do t[tostring(i)] = i*i end

     for i = 1, 1e4 do
       for k, v in pairs(t) do end
     end

Now the results are:

Lua 4.0.1: ~11.4 seconds
Lua 5.0.2: ~27.9 seconds
Lua 5.1-alpha: ~26.1 seconds

Again, the setup of the table was not timed.

--
Wim