Two addons showing high CPU usage, despite being small.
Hi, I was having some fps issues so I downloaded an addon monitoring addon and noticed that two small addons were showing high CPU usage relative to their size. Could anyone take a look for me?
Thanks. 1. Lua Code:
2. Lua Code:
|
The size of the code doesn't matter as far as CPU is concerned - what it's actually doing, and how often, does.
I'm not sure what you're doing in the second snippet, so I cannot really comment. In the first snippet, however, you are performing calculations whenever the GameTooltip updates in its OnUpdate script. The OnUpdate script fires every time your screen is updated, so if you are getting 120FPS in game your code is running that many times per second. |
Quote:
The second part hides the little sparkle animation that plays on an action button when a cooldown finishes. |
The first snippet of code is using 80% of my CPU usage and it just keeps going up and up and up indefinitely.
Is something in it poorly written or is that just the nature of performing those functions? If the latter, I'll just scrap the addon. |
When you hook a script like GameTooltip:HookScript("OnUpdate"), its cpu usage is not measured correctly, it combines every other piece of code that's run along with the hooked function and counts that as the cpu used.
If you created your own frame to run the same OnUpdate script from, it would likely report a lower cpu usage. That being said, this is not a very efficient function, and not something that needs to be run OnUpdate. While I doubt this is using enough cpu to have an impact on your frame rate, the only time this code needs to run is you first mouse over a unit and when their target changes, so it could be moved into a function called by the OnTooltipSetUnit event, and a frame with RegisterUnitEvent('UNIT_TARGET', 'mouseover') on it. First what you should do is just disable these 2 addons and see if it makes any difference in your frame rate, that will tell you if the problem is elsewhere. |
All times are GMT -6. The time now is 05:57 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI