运行效率:本地变量 * 4 ≈ 全局变量 * 3 ≈ 本地函数 * 2 ≈ 全局函数。测试数据:4/5/9/12
local a = 0
local b = 0
local function CheckFun()
return false
end
rawset(_G, "CheckFunTest", CheckFun)
rawset(_G, "CheckATest", os.time())
a = os.time()
for i = 1, 100000000 do
if CheckFunTest() then
end
end
b = os.time()
error(LTAG.zhouqiang, b - a)
a = os.time()
for i = 1, 100000000 do
if CheckFun() then
end
end
b = os.time()
error(LTAG.zhouqiang, b - a)
a = os.time()
for i = 1, 100000000 do
if CheckATest then
end
end
b = os.time()
error(LTAG.zhouqiang, b - a)
a = os.time()
for i = 1, 100000000 do
if a == -2 then
end
end
b = os.time()
error(LTAG.zhouqiang, b - a)