I'd suggest xdebug
and kcachegrind
to profile and analyse the behaviour of your code.
Configure xdebug like this to enable profiling:
xdebug.profiler_enable = 1
xdebug.profiler_output_name = xdebug.out.%t
xdebug.profiler_output_dir = /tmp
xdebug.profiler_enable_trigger = 1
If you pass XDEBUG_PROFILE
as POST or GET paramteter, xdebug will produce profiling data in the configured location.
Open these files with kcachegrind to drill into it.
Beware: Execution while profiling will take its time, and the files produced can get pretty big -- have an eye on diskusage.