My environments include OS X with Zend Server CE and Ubuntu Server, Apache 2. Developing with Symfony 1.4 & Doctrine on PHP 5.3.
I'm searching for a profiler that can be used with command-line PHP scripts as well as Apache-invoked PHP. At the moment my need for command-line is actually more urgent than the web scripts.
I have already done some brute-force timing via logging microtime() intervals to good effect but I'd like to be able to get total times for each function being called and without so much hand-coding.
While my main concern is time profiling, a memory profiler would also be very useful. Similar to using microtime() I've occasionally had to make repeated calls to memory_get_usage() before and after instantiating large objects or collections to get an idea how big their footprint is.
Here's the final solution that I'm quite happy with.
I tried installing XDebug 2.1.1 via the command:
pecl install xdebug
However, this was failing miserably with this kind of error:
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. ERROR: `phpize' failed
After a bunch of searching I came across someone else who had tried this on OS X. Fortunately they mentioned that installing Apple Xcode would provide the autoconf, phpize and other needed tools.
I got Xcode 3 and installed that, then re-tried the pecl install xdebug
and it worked beautifully. After learning how to enable xdebug in my CLI instance of PHP and figuring out where the output files went, I then moved on to Webgrind. Within a couple minutes of looking at my first webgrind report, I was happily pinpointing the areas of my symfony task to optimize. It has been fabulous.
Also in my searching I happened across this promising page about how to use Xdebug for MEMORY profiling. I haven't yet attempted this but wanted to add it here in case it helps anyone else.
I received one helpful comment with a link to a relevant discussion and two partial answers which were both helpful. I gave each of those responders an upvote and indicated so.
I wish S.O. didn't seem to place such emphasis on accepting a single answer, but since it does, I'm writing a more complete answer and accepting it but made sure to give all the helpful responders upvotes. Thanks again.