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

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

//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迭代器接口Iterator用法分析

本文实例讲述了PHP迭代器接口Iterator用法。分享给大家供大家参考,具体如下: PHP Iterator接口的作用是允许对象以自己的方式迭代内部的数据,从而使它可以被循环访问,It...

设置php页面编码的两种方法示例介绍

1:输出meta标签: 1、在php mvc的控制器里面或php页面echo '<meta http-equiv="content-type" content="text/html...

探讨GDFONTPATH能否被winxp下的php支持

php学习中遇一问题,使用GD库绘图,设置字体路径变量:putenv('GDFONTPATH=c:\windows\Fonts');$fontname='arial';$bbox=ima...

简化php模板页面中分页代码的解析

在使用模板的时候,会遇到这么一个问题:显示分页信息时操作麻烦,n多个模板都有分页块。 例如: ---共 20 条记录,当前 3/5 页 首页 上一页 下一页 尾页 GO----- 初遇到...

php json_encode奇怪问题说明

json_encode 只支持utf-8格式这个就不多说了 复制代码 代码如下: $array = array ( [0] => array ( [sale_unit_detail...