php程序执行时间

php   2008-06-25 11:14   阅读48   评论0  
字号:    

 

 一、

$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";

评论(?)
阅读(?)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
网易公司版权所有 ©1997-2009