Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "socket"
- l = {}
- for i=1,3000 do
- l[i - 1] = function() math.random(1) end -- populate
- end
- function test()
- local l = l
- for i,d in pairs(l) do
- d()
- end
- end
- function test_global()
- for i,d in pairs(l) do
- d()
- end
- end
- print "testing local"
- local starttime = socket.gettime()
- for i=1,6000 do
- test()
- end
- local endtime = socket.gettime()
- print("Took " .. ((endtime - starttime) * 1000) .. " milliseconds")
- print "testing global"
- starttime = socket.gettime()
- for i=1,6000 do
- test_global()
- end
- endtime = socket.gettime()
- print("Took " .. ((endtime - starttime) * 1000) .. " milliseconds")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement