PHP 计算页面执行时间
PHP 计算页面执行时间
<?php
< ?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0; function start()
{
$this->StartTime = $this->get_microtime();
} function stop()
{
$this->StopTime = $this->get_microtime();
} function spent()
{
return round(($this->StopTime – $this->StartTime) * 1000, 1);
} } //例子
$runtime= new runtime;
$runtime->start()
for($i=0; $i<1000000; $i++)
{
$a += $i;
} //你的代码结束 $runtime->stop();
echo “页面执行时间: “.$runtime->spent().“ 毫秒“;
?>
< ?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0; function start()
{
$this->StartTime = $this->get_microtime();
} function stop()
{
$this->StopTime = $this->get_microtime();
} function spent()
{
return round(($this->StopTime – $this->StartTime) * 1000, 1);
} } //例子
$runtime= new runtime;
$runtime->start()
;
//你的代码开始
$a = 0;for($i=0; $i<1000000; $i++)
{
$a += $i;
} //你的代码结束 $runtime->stop();
echo “页面执行时间: “.$runtime->spent().“ 毫秒“;
?>
function get_microtime()
{
list($usec, $sec) = explode(‘ ‘, microtime());
return ((float)$usec + (float)$sec);
}
有点相关的文章
- PHP 正则表达式 (1.000)
- php将HTML转换为txt文本的函数 (1.000)
- PHP 截取字符串专题 (1.000)
- PHP中判断一个数组是否为空? (1.000)
- PHP连接字符串性能比较 (1.000)
- php写入、删除、复制文件例子 (RANDOM - 0.500)
搜索引擎提交站点地图,可以有多种方式,不过使用wp的话,有一个很好用的插件Google XML Sitemaps(下载和使用方式,在此不多说,如果En文搞不好,可以联系我