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.
The PECL APD extension is used as follows:
After, parse the generated file using
pprofp
.Example output:
Warning: the latest release of APD is dated 2004, the extension is no longer maintained and has various compability issues (see comments).