What you are talking about is profiling. Although it is possible to "roll your own", (and you are on the right track in that regard), there are a lot of helpful things out there that will do the heavy lifting for you.
If you want, you can always do what you suggested and smooth out the deviations by looping through multiple iterations of your tests, but if you want comprehensive profiling of all of your PHP I recommend the "xdebug" answer to this question: Simplest way to profile a PHP script
It worked well for me.