XDEBUG profiler results are different each time
Is this normal to get different results each time I execute my code?
I've written a small piece of code and whenever I run it, I get different results. Say I call two different functions in my code, sometime's the cost of Func1 is 44%, Func2 is 25%, sometimes it's 38%, 33% respecti开发者_开发问答vely!
What should I do to get more accurate results?
In most cases it's impossible to recreate the same results on a dynamic website, various factors like the amount of records in a database and background tasks will skew results. To help make sense of the XDebug results it's probabaly worth installing a nice frontend.
I use Webgrind: http://code.google.com/p/webgrind/
Preview: http://jokke.dk/media/2008-webgrind/webgrind_large.png
It might be worth putting a few var_dumps inside the function to figure when the varied results occur, if you can isolate them you'll know how to speed up the whole function.
精彩评论