Originally Posted by Kagura
Actually it won't be slower. But Phanx is right, I think the thread is derailing too much from "simple optimization" to getting every bit of performance you can possibly get.
p.s. If you are really curious, the test results with your suggestion is : here
|
Yeah but in this test you added another bunch of variable to lookup for the 1st and the 3rd version again. If you want them to test properly then you should have 1 line to set up the variables and 1 lookup line (Where you upvalue thoose variables). Which is already is in the 1st and the 3rd version.
Lua Code:
function UnitAura(unitId, index)
end
local time = 1000000
time = debugprofilestop()
for j = 1, 1000000 do
local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
for i = 1, 40 do
name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
end
end
print(format("%.0f ms", debugprofilestop() - time))
time = debugprofilestop()
for j = 1, 1000000 do
for i = 1, 40 do
local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
name = 1
rank = 1
icon = 1
count = 1
dispelType = 1
duration = 1
expires = 1
caster = 1
isStealable = 1
shouldConsolidate = 1
spellID = 1
canApplyAura = 1
isBossDebuff = 1
value1 = 1
value2 = 1
value3 = 1
end
end
print(format("%.0f ms", debugprofilestop() - time))
time = debugprofilestop()
for j = 1, 1000000 do
for i = 1, 40 do
local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
end
end
print(format("%.0f ms", debugprofilestop() - time))
Tested it ingame:
7980 ms
8073 ms
8664 ms
Also it's pretty fast with integers only, much slower with strings/other variables. ~8500 ms
~600 ms gain on a million calls.