Hooking my own functions
Hey all
I'm trying to so find some performance leaks in my addons code. My first thought was to hook everything and to see how long it takes. So I came up with this: Lua Code:
Works as expected. But ... to see how much time function needs a post-hook via hooksecurefunc obv. isn't enough. So I tried this: Lua Code:
To my surprise that didn't worked. It iterates the functions. The line print(tmp == v) returns false. I can call ProfilerTestAddon:Test1() and it does print "Test2". But that's it. Profiler() is not called. What the hell could be wrong with it? :) [e] Even Lua Code:
|
Where do you suppose Profiler would be called? What I think you might be missing here is that reassigning the loop variables won't actually change the table, which I think is what you're looking to do. Reassigning v won't change the value of table[i] in the same way that this "doesn't work":
Code:
a = 1 |
Doh. Stupid me. *fp*
Thanks Lombra. |
While this is hopefully only for local testing ... never forget the underscore to be defined local ;)
Lua Code:
|
Quote:
Don't know if I'm the only one who never heard of it, but I just realized that there is something like GetFunctionCPUUsage(). |
Even for local testing you should be vigilant in avoiding global leaks, especially generic ones like _, as you can easily taint vast swaths of the UI and inadvertently let other addons (and even the Blizzard UI code) mess with your code. It's just not that hard to type the "local" keyword in front of your variable declaration. Stop being so lazy; even I'm not that lazy. ಠ_ಠ
|
Quote:
There was only this single addon loaded, and in this specific situation I didn't care about any Blizzard stuff that could be affected by it. I would never do this outside this specific circumstances. You see, there's no need to get ಠ_ಠ. (whatever this means :)) |
How are you on on the internet and don't know what the look of disapproval is? :(
|
Quote:
That reminds me on a speech that was deliverd by my fellow Chancellor last year. At least I'm not alone. :D |
Quote:
|
All times are GMT -6. The time now is 07:45 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI