All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
PHP技巧:一个页面执行时间类_[PHP教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/17 7:35:59 Browse times: 498 Comment times: 0

PHP技巧:一个页面执行时间类_[PHP教程]


Head photo

Go homepage
Upload pictures
Write articles

PHP技巧:一个页面执行时间类_[PHP教程] PHP代码
class Timer//页面执行时间类
{
var starttime;//页面开始执行时间
var stoptime;//页面结束执行时间
var spendtime;//页面执行花费时间

function getmicrotime()//获取返回当前微秒数的浮点数
{
list(usec,sec)=explode(" ",microtime());
return ((float)usec + (float)sec);
}

function start()//页面开始执行函数,返回开始页面执行的时间
{
this->starttime=this->getmicrotime();
}

function display()//显示页面执行的时间
{
this->stoptime=this->getmicrotime();
this->spendtime=this->stoptime-this->starttime;
return round(this->spendtime,10);
}
}
/*调用方法
timer=new Timer();
timer->start();
/*在此处放入你要执行的脚本或代码
for(i=0;i<100000;i++)
{
echo i;
echo "";
}
*/
//echo "

执行该代码花费时间".timer->display()."秒";
?>





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.