XDebug is a great PHP debugging tool, but it also comes with a very useful profiler that can tell you all sorts of information about your PHP application. This includes things like memory footprint and CPU load but will also have detailed information about the entire callstack of the code that was run. To enable the profiler part of XDebug you just need to set up a few rules in your xdebug.ini file.
On some systems the profiler will cause the application to slow down so I normally explicitly set profiler_enable to be 0 (the default value) and use the profiler_enable_trigger to only profile the application when I need to. This helps as you can quickly end up with lots and lots of profiler output files, which can be a pain to inspect. With the profiler_enable_trigger in place you then append XDEBUG_PROFILE=true to the URL at any time in order to run a profile. Note that any positive value will cause the profiler to trigger.
The only problem I have is remembering the trigger needed to call the profiler, which I normally end up having to look up. So I created a little bookmarklet that will take the current URL and just append the correct flag.
Here it is in link form.
Just drag the above bookmarklet into your bookmark folder and you can run the XDebug profiler whenever you want with just a click of a button.
To view the output of the XDebug profiler I can recommend using KCachegrind. This provides all of the information like CPU load and memory uses as well as interactive graphs of the callstack.