Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-05-13, 10:41 AM   #19
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Kagura View Post
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:
  1. function UnitAura(unitId, index)
  2. end
  3.  
  4. local time = 1000000
  5.  
  6. time = debugprofilestop()
  7. for j = 1, 1000000 do
  8.         local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
  9.         for i = 1, 40 do
  10.                 name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
  11.         end
  12. end
  13. print(format("%.0f ms", debugprofilestop() - time))
  14.  
  15. time = debugprofilestop()
  16. for j = 1, 1000000 do
  17.         for i = 1, 40 do
  18.                 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
  19.                 name = 1
  20.                 rank = 1
  21.                 icon = 1
  22.                 count = 1
  23.                 dispelType = 1
  24.                 duration = 1
  25.                 expires = 1
  26.                 caster = 1
  27.                 isStealable = 1
  28.                 shouldConsolidate = 1
  29.                 spellID = 1
  30.                 canApplyAura = 1
  31.                 isBossDebuff = 1
  32.                 value1 = 1
  33.                 value2 = 1
  34.                 value3 = 1
  35.         end
  36. end
  37. print(format("%.0f ms", debugprofilestop() - time))
  38.  
  39. time = debugprofilestop()
  40. for j = 1, 1000000 do
  41.         for i = 1, 40 do
  42.                 local name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3
  43.                 name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura("player", i)
  44.         end
  45. end
  46. 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.

Last edited by Resike : 08-20-14 at 09:25 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » About add-ons optimization

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off