3 ms·
I was getting some spurious runs where the array access was slower, but didn't think it was worthwhile to mention in the post. Immediately after posting my curi
by wahern 8y ago
I was getting some spurious runs where the array access was slower, but didn't think it was worthwhile to mention in the post. Immediately after posting my curiosity got the better of me. After filling in _G[1,2048] the times were consistently the same. The code I was playing with:
local n = 16777216
local _G = _G
for i=1,2048 do
_G[i] = i
end
do
local start = os.clock()
for i=1,n do
local f = _G["print"]
end
print(os.clock() - start)
end
do
local start = os.clock()
for i=1,n do
local f = _G[42]
end
print(os.clock() - start)
end