那么有没有更好的方法来分析代码:
$start1 = microtime(TRUE);
for($i=0;$i<count($array);$i++)
{
//do something
}
$time1 = microtime(TRUE) - $start1;
如果您在安装 Xdebug 时遇到困难,请使用 Xdebug 或 Zend Debugger。
他们的分析器将为您计时,无需修改您的代码。
http://www.zend.com/en/community/pdt
http://devzone.zend.com/article/2899-Profiling-PHP-Applications-With-xdebug - 一系列关于 xdebug 的教程。
如果不使用外部工具,我会说你已经尽力了。
如果您想使用为此目的而构建的工具,那么其他答案都是固定的。