If you're interested in doing code profiling, KCachegrind is a great utility to investigate what part of your code is hogging CPU time. If you're on a debian or ubuntu machine, it is simple to install. If you're on OSX... well you've got a bit of work to do. You need to install a few things to get KCachegrind to work: fink, xdebug, OSX's X11, Firefox xdebug, and PHP. I use the Entropy version of PHP as it has many extensions compiled in (eg: curl, ftp, etc) and I'm lazy.
Installing fink, X11, php, and the firefox xdebug extension is straight forward. To get xdebug up and running, you need to install it. There are some good instructions on how to do this that James Welford wrote. Note that you'll need to adapt the instructions if you're using MAMP or the stock Apple php.
To configure php to use xdebug, you need to update your php.ini file with the following items. See Chris Shattuck's instructions for more details.
xdebug.remote_port=9000 ; Choose a port
; profiler settings
xdebug.profiler_output_name = cachegrind.out.%s
At this point, you should be able to verify that you are getting grind files in /var/log/xdebug once you have restarted apache. Note that you enable the logging of your localhost code by using the FireFox plugin in the lower right hand side of your screen. You need to click on both buttons. The more challenging part is getting KCachegrind up and running.
While fink is a package manager, I find that it often is a troublesome to work with. Using apt-get to install files does not always work for me- perhaps it is my configuration but I did get things set up after a bit of annoyance. Here is what I finally used:
fink self-update fink update-all
At this point you should be able to go get a cup of coffee, read a book, and get some other work done. Once this is complete, hopefully you will be able to fink (apt-get) to install KCachegrind:
sudo apt-get update sudo apt-get upgrade sudo apt-get install kcachegrind This is going to install a large amount of files- a full KDE installation. Time to go get another cup of coffee.
Now that you have KDE and KCachegrind installed, in a terminal session, type "kcachegrind" which will launch X11 and you should have your profiling environment good to go. Grab your files from /var/log/xdebug and go at it!