php程序执行时间
一、
$stime=microtime(true); //获取程序开始执行的时间
echo "hello world"; //你执行的代码
echo "<br>";
$etime=microtime(true);//获取程序执行结束的时间
$total=$etime-$stime; //计算差值
echo $stime."<br>";
echo $etime."<br>";
echo "<br />{$total} times";
二、
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
// Sleep for a while
usleep(100);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";