获取页面执行时间是这样写的吗?

#1 youngqj

$mtime= explode(' ', microtime()); 

$starttime = $mtime[1] + $mtime[0];

$totaltime = number_format(($mtime[1] + $mtime[0] -$starttime), 6);

$this->booterinfo = 'Processed in '.$totaltime.' second(s)';


是不是这样的? 谢谢啊

2010-04-16 22:54:14

#2 azwl

我是这样写的

    $stime = gettimeofday();
      $etime = gettimeofday();
      页面耗时: ($etime['usec'] - $stime['usec']) / 1000000  毫秒

2010-04-16 23:40:05

#3 jake

先看看php手册上面的例子http://cn2.php.net/manual/en/function.microtime.php

然后,在speedphp内,可以将开始的时间计算$time_start = microtime_float();放到入口文件的第一行(index.php)

最后在 require(SP_PATH."/SpeedPHP.php");  的后面加上最后的输出
$time_end = microtime_float();
$time = $time_end - $time_start;
echo '';

当然,你希望赋值到模板上也是可以的,正如你写的$this->booterinfo = 。不过这样不是很准确,因为模板本身还是需要继续处理而花费时间的。

2010-04-17 09:01:20

#4 youngqj

:victory:恩谢谢啊 学习了

2010-04-17 21:52:35