PHP计算代码运行时间的代码,可以用来比较程序的执行时间
代码:
<?php
function get_microtime(){
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
$s = get_microtime();
for($i=0;$i<10000;$i++){
echo $i;
}
$e = get_microtime();
$t = $e-$s;
echo "执行时间:".$t;
?>