function f_run_time()
{
$time_test=microtime();
list($ten_thousand,$sec)=explode(" ",$time_test);
$time=((float)$ten_thousand+(float)$sec);
echo $time."<br>";
return $time;
}
<script language=javascript>
<!--
function jishi(){
OpenTime=new Date()
}
function likai(){
CloseTime=new Date()
staytime=(CloseTime.getTime() - OpenTime.getTime())
miaoshu=Math.round(staytime / 1000);
alert(miaoshu+'秒')
//-->
}
</script>
{
$time_test=microtime();
list($ten_thousand,$sec)=explode(" ",$time_test);
$time=((float)$ten_thousand+(float)$sec);
echo $time."<br>";
return $time;
}
<script language=javascript>
<!--
function jishi(){
OpenTime=new Date()
}
function likai(){
CloseTime=new Date()
staytime=(CloseTime.getTime() - OpenTime.getTime())
miaoshu=Math.round(staytime / 1000);
alert(miaoshu+'秒')
//-->
}
</script>
function runtime($mode=0) {
static $t;
if(! $mode) {
$t = microtime();
return;
}
$t1 = microtime();
list($m0,$s0) = split(" ",$t);
list($m1,$s1) = split(" ",$t1);
return sprintf("%.3f ms",($s1+$m1-$s0-$m0)*1000);
}runtime(); //计时开始
/*
待计时的代码段
*/
echo runtime(1); //计时结束并输出计时结果
佩服
to 楼猪:你给不给分是你的事,别人回复不回复你好象管不着吧!!!!!
* 取得页面的执行时间类
*
* 初始化时执行 startTime 方法取得初始化时间,使用 timePassed 方法计算时间差。
*
* @name : Debug
* @author : ShenKong <[email protected]>
* @version : $id
* @package : Debug
* @copyright: ShenKong (http://www.openphp.cn)
*/
class Debug
{
/**
* @private 初始化类的当前时间
*/
var $startTime; /**
* @return void
* @desc 初始化,构造函数
*/
function Debug()
{
$this->startTime = $this->getTime();
} /**
* @return double
* @desc 返回调用时的时间
*/
function getTime()
{
$microTime = microtime();
$microTime = explode(" ", $microTime);
// $microTime = doubleval($microTime[1]) + doubleval($microTime[0]);
$microTime = $microTime[1] + $microTime[0];
return $microTime;
} /**
* @return string 返回时间差
* @param int $length 时间精确度,数值表示小数点后几位
* @desc 计算调用 getTime 方法和当前时间的差值
*/
function timePassed($length = 3)
{
$endTime = $this->getTime();
$timePassed = ($endTime - $this->startTime) * 1000;
$timePassed = round($timePassed, $length);
return $timePassed . " ms";
}
}
...........print(sprintf("Processed:%s sec", number_format(array_sum(split(' ', microtime())) - $begin, 3)));