profiler.php:
<?php
function __profiler__($cmd = false) {
static $log, $last_time, $total;
list($usec, $sec) = explode(" ", microtime());
$now = (float) $usec + (float) $sec;
if($cmd) {
if($cmd == 'get') {
unregister_tick_function('__profile__');
foreach($log as $function => $time) {
if($function != '__profile__') {
$by_function[$function] = round($time / $total * 100, 2);
}
}
arsort($by_function);
return $by_function;
}
else if($cmd == 'init') {
$last_time = $now;
return;
}
}
$delta = $now - $last_time;
$last_time = $now;
$trace = debug_backtrace();
$caller = $trace[1]['function'];
@$log[$caller] += $delta;
$total += $delta;
}
__profiler__('init');
register_tick_function('__profiler__');
declare(ticks=1);
?>
Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
lacks GUI. We use our own GUI (can't give, sorry).
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Hard core programmers like you'll always write codes and would
restrain to use other tools:( But, I would suggest you to try APD
<http://in.php.net/apd> and see the difference.
> Never tried. But, I use APD <http://in.php.net/apd>. It's neat, but
> lacks GUI. We use our own GUI (can't give, sorry).
APD is a debugger, not a profiler. Thanks.
"APD is the Advanced PHP Debugger. It was written to provide profiling and
debugging capabilities for PHP code"
And it goes on with an example of profiling later on the page.
--
Andy Hassall :: an...@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool