Reducing CPU usage of my addons?
Hi all,
I have made a few small addons and they have been fine but now I am looking at making a slightly bigger addon but this has caused me trouble because although I can make the addon do what I want I can't work out a way to stop the addon taking up 50% CPU for 1/2 sec every time it does a check... I have searched on the forums but can't find anything even close... I would also like to change a few other addons that do the same as I the map open as a kinda minimap all the time and a few addons don't expect this so blip 30-80% CPU every now and then when they do there checks. This causes the game to stop for this fraction of a second... anoying as ppl jump and arn't where they where when you clicked! :-| Please help! LOL Zas |
I'm not a coder myself, but i'm pretty sure they (coders) would like to see the code before being able to say anything about what could be causing this.
You could also go ask at wowace.com forums in the developers section. |
Moved to the appropriate section.
Also, there is no way we could be able to answer this without your code. You're certainly doing something wrong, but without your code we wouldn't be able to tell what it is. |
to note Zasurus if you rely on the % on my mod broker_cpu or performancefu it does not mean it takes 50% of the cpu this is a percentage of the growth globally so you can compare how performs the growth between X and Y mods, nor if the growth of Z mod that could be yours you know usually takes 0,15% and that time for the same thing it takes 15% then you could sort out some coding errors that way, nor benchmarking etc but that is not really a percent of your cpu used because there is no ways to know that, the wow api for cpu only returns the time the mod worked, and for memory the amount actually used, that % value is much like a speedmeter you could have in a car, nice to know how many meter you do but at which speed too.
But globally a growth of 50% isnt that a big deal if for exemple this is about opening an option panel etc but if thats in a frequently used function like a loop that could be a problem But I will update the description of my mod to make it more intructive on that subject, I agree the % value could be badly interpreted |
Quote:
Zas |
Quote:
|
It may not be code-independant, depending on what you're doing in your code. If, for example, you're calling a function to get a value that never changes for every iteration in a loop - that could be optimized by assigning the returned value to a local variable exactly once and using it in the iterations.
If you're asking how to delay execution for 0.05 seconds, that depends on what you're doing - is delaying really what you want to do, or would an optimization or two remove the CPU spikes and allow the code to otherwise run as-is? |
It would probably be best if you linked us a pasty.net of your code, so we can see what's going on. =)
|
Quote:
|
You could 'slow down' code in a way...
Use OnUpdate(elapsed) and have it run your function at your discretion. Look into making a Clock type addon to see how it's done to update once every second (for example) |
All times are GMT -6. The time now is 02:31 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI