加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php代码运行时间查看类代码分享

发布时间:2020-12-13 05:58:18 所属栏目:PHP教程 来源:网络整理
导读:div class="codetitle" a style="CURSOR: pointer" data="9159" class="copybut" id="copybut9159" onclick="doCopy('code9159')" 代码如下: div class="codebody" id="code9159" //date:2011-08-05 class RunTime//页面执行时间类 { private $starttime;//

<div class="codetitle"><a style="CURSOR: pointer" data="9159" class="copybut" id="copybut9159" onclick="doCopy('code9159')"> 代码如下:<div class="codebody" id="code9159">
//date:2011-08-05
class RunTime//页面执行时间类
{
private $starttime;//页面开始执行时间
private $stoptime;//页面结束执行时间
private $spendtime;//页面执行花费时间
function getmicrotime()//获取返回当前微秒数的浮点数
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//页面开始执行函数,返回开始页面执行的时间
{
$this->starttime=$this->getmicrotime();
}
function end()//显示页面执行的时间
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "

运行时间:".round($this->spendtime,10)."秒

";
}
}
/*调用方法
$timer=new Runtime();
$timer->start();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读