Simplest way to profile a PHP script

What’s the easiest way to profile a PHP script?

I’d love tacking something on that shows me a dump of all function calls and how long they took but I’m also OK with putting something around specific functions.

I tried experimenting with the microtime function:

$then = microtime();
myFunc();
$now = microtime();

echo sprintf("Elapsed:  %f", $now-$then);

but that sometimes gives me negative results. Plus it’s a lot of trouble to sprinkle that all over my code.

13 Answers
13

Leave a Comment