Profiling a PHP application
There are quite some ways to profile PHP applications, as you can for example read in Eric Hogue's Blog. We've been using Xdebug with KCachegrind at Yahoo! after rolling out the new Movies page for Europe. Compared to XHProf (check documentation here) with XHGui that's quite complicated and you can't use it in a production environment - at least not on a regular basis (aka just keep it running).
If you want to give it a try you don't have to download and manually install (as Eric suggests) because it's a pecl package, so you can simply install it with:
sudo pecl install xhprof
Then you should follow the git installation as Eric writes under XHProf. I installed it under "/usr/local", so changed to that directory and issued the "git clone" command there having the XHGui stuff under "/usr/local/xhprof" now.
If you want to have nice call graphs (see Eric's blog entry for a sample image) you'll have to install Graphviz which on Ubuntu/Debian is nothing more than a:
sudo apt-get install graphviz
I recommend to follow Paul Reinheimer's blog about using XHGui - he's the author of that package.
Here are some configuration hints for the "config.php" file, as Paul's blog entry and the comments in the file don't make everything clear:
$_xhprof['display'] = false; $_xhprof['doprofile'] = false;
The display param only needs to be true if you want a link to the profiling result page in the XHGui which imho only makes sense if you "manually" profile with ?_profile=1. If the doprofile param is true than every request will be profiled - not good for a production environment. Use the weight param to profile only some requests and you should be fine.
Only one thing does not yet work as expected in my setup - only page requests via browser seem to be profiled (or logged by the XHGui). API like request (via Zend_Http_Client in my case) don't show up. I'll update this post once I find the answer.
Read more about PHP profiling in those slides from Justin Carmony.








