View Single Post
08-20-14, 12:30 PM   #11
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Lua Code:
  1. local function UnitDebug(unit,index)
  2.   return "name", "rank", "icon", 1, "debuffType", 1, 1, "unitCaster", true, true, 1
  3. end
  4.  
  5. local d = debugprofilestop
  6. local function OnEvent()
  7.   do
  8.     local time = d()
  9.     local debuffList = {}
  10.     local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
  11.     for index=1,1e5 do
  12.       for i=1,40 do
  13.         name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebug("player",i)
  14.         debuffList[spellId] = {name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId}
  15.       end
  16.     end
  17.     print(d() - time)
  18.   end
  19.   print("~~~~~~~~~~")
  20.   do
  21.     local time = d()
  22.     local debuffList = {}
  23.       for index=1,1e5 do
  24.       for i=1,40 do
  25.         local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebug("player",i)
  26.         debuffList[spellId] = {name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId}
  27.       end
  28.     end
  29.     print(d() - time)
  30.   end
  31.  
  32. end
  33.  
  34. local f = CreateFrame("Frame")
  35. f:SetScript("OnEvent",OnEvent)
  36. f:RegisterEvent("PLAYER_LOGIN")

The lower one is faster by ~4%.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 08-20-14 at 12:34 PM.
  Reply With Quote