Solution 1:

I have actually done some optimisation work last week. XDebug is indeed the way to go.

Just enable it as an extension (for some reason it wouldn't work with ze_extension on my windows machine) , setup your php.ini with xdebug.profiler_enable_trigger=On and call your normal urls with XDEBUG_PROFILE=1 as either a get or a post variable to profile that very request. There's nothing easier!

Also, i can really reccommend webgrind , a webbased (php) google Summer Of Code project that can read and parse your debug output files!

Solution 2:

Here is a nice tip.

When you use XDebug to profile your PHP, set up the profiler_trigger and use this in a bookmarklet to trigger the XDebug profiler ;)

javascript:if(document.URL.indexOf('XDEBUG_PROFILE')<1){var%20sep=document.URL.indexOf('?');sep%20=%20(sep<1)?'?':'&';window.location.href=document.URL+sep+'XDEBUG_PROFILE';}

Solution 3:

take a look into xdebug, which allows in-depth profiling. And here's an explanation of how to use xdebug.

Xdebug's Profiler is a powerful tool that gives you the ability to analyze your PHP code and determine bottlenecks or generally see which parts of your code are slow and could use a speed boost. The profiler in Xdebug 2 outputs profiling information in the form of a cachegrind compatible file.

Kudos to SchizoDuckie for mentioning Webgrind. This is the first I've heard of it. Very useful (+1).

Otherwise, you can use kcachegrind on linux or its lesser derivative wincachegrind. Both of those apps will read xdebug's profiler output files and summarize them for your viewing pleasure.