Lua Code:
local function UnitDebug(unit,index)
return "name", "rank", "icon", 1, "debuffType", 1, 1, "unitCaster", true, true, 1
end
local d = debugprofilestop
local function OnEvent()
do
local time = d()
local debuffList = {}
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
for index=1,1e5 do
for i=1,40 do
name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebug("player",i)
debuffList[spellId] = {name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId}
end
end
print(d() - time)
end
print("~~~~~~~~~~")
do
local time = d()
local debuffList = {}
for index=1,1e5 do
for i=1,40 do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebug("player",i)
debuffList[spellId] = {name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId}
end
end
print(d() - time)
end
end
local f = CreateFrame("Frame")
f:SetScript("OnEvent",OnEvent)
f:RegisterEvent("PLAYER_LOGIN")
The lower one is faster by ~4%.