您的位置:首页 > 其它

wordpress优化教程之页面执行效率查询

2013-07-03 16:07 537 查看
一个优秀网站速度一定是非常快的,所以我们建设的网站一定要保证速度,静态文件方面我们可以启用cdn来加速,动态脚本的优化我们只能尽量的减少查询次数以及提高服务器的配置。下面上一个输出wordpress执行效率的代码。
<?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0;
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
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()." 毫秒";
?>
将以上代码放到footer.php适当的位置,就可以了看到wordpress当前页面的执行效率了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐