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基于dom实现读取图书xml格式数据的方法

本文实例讲述了php基于dom实现读取图书xml格式数据的方法。分享给大家供大家参考,具体如下: <?php $doc = new DOMDocument(); $...

PHP实现变色验证码实例

复制代码 代码如下: <?php header("Content-type: image/png,charset='utf-8'"); $im = imagecreatetruec...

让你的PHP7更快之Hugepage用法分析

本文实例讲述了让你的PHP7更快之Hugepage用法。分享给大家供大家参考,具体如下: PHP7刚刚发布了RC4, 包含一些bug修复和一个我们最新的性能提升成果(NEWS), 那就是...

PHP include_path设置技巧分享

PHP include_path设置技巧分享

1.include_path的意义 当时候函数include(),require(),fopen_with_path()函数来寻找文件时候.在不设置include_path的情况下,这些...

php通过array_shift()函数移除数组第一个元素的方法

本文实例讲述了php通过array_shift()函数移除数组第一个元素的方法。分享给大家供大家参考。具体分析如下: 下面的代码通过array_shift()函数加while循环不断移除...