[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why can't I do for...in on a table?
- From: Wim Couwenberg <wcou@...>
- Date: Mon, 12 Sep 2005 16:51:29 +0200
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