Jump to content

My message is blocked by your protection system


Maris

Recommended Posts

Let's see if I can get around this...

a = {}
b = {}
for i=1,50000 do
    a = i
    b[string.char(math.random(97,122)) .. tostring(i) .. string.char(math.random(97,122)) .. string.char(math.random(97,122))] = i
end

-‍-Time: 4.034
function test_a1()
    for i=1,50000 do
        a = a + 1
    end
end

-‍-Time: 2.270
function test_a2()
    local a = a
    for i=1,50000 do
        a = a + 1
    end
end

-‍-Time: 2.192
function test_a22()
    local a = a
    for i=1,#a do
        a = a + 1
    end
end

-‍-Time: 3.730
function test_a3()
    local a = a
    for i,v in ipairs(a) do
        a = v + 1
    end
end

-‍-Time: 4.364
function test_a4()
    for i,v in ipairs(a) do
        a = v + 1
    end
end

-‍-Time: 8.196
function test_b1()
    for k,v in pairs(b) do
        b[k] = v + 1
    end
end

-‍-Time: 7.654
function test_b2()
    local b = b
    for k,v in pairs(b) do
        b[k] = v + 1
    end
end

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...