手机
当前位置:查字典教程网 >编程开发 >php教程 >php代码运行时间查看类代码分享
php代码运行时间查看类代码分享
摘要:复制代码代码如下://date:2011-08-05classRunTime//页面执行时间类{private$starttime;//页面...

复制代码 代码如下:

//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 "<p>运行时间:".round($this->spendtime,10)."秒</p>";

}

}

/*调用方法

$timer=new Runtime();

$timer->start();

【php代码运行时间查看类代码分享】相关文章:

php curl请求信息和返回信息设置代码实例

php线性表的入栈与出栈实例分析

php分页的功能模块分享

一棵php的类树(支持无限分类)

php三元运算符知识汇总

php代码优化及php相关问题总结

PHP滚动日志的代码实现

php操作memcache缓存方法分享

php操作redis缓存方法分享

php对数组内元素进行随机调换的方法

精品推荐
分类导航