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编程获取音频文件时长的方法【基于getid3类】

本文实例讲述了PHP编程获取音频文件时长的方法。分享给大家供大家参考,具体如下: 问题: 昨天在新增论坛功能的时候,移动端显示音频文件需要知道是多长的音频; 具体解决方案如下: 首先就是...

解析yii数据库的增删查改

1. 存取数据库方法存储第一种存表时候用到例子:复制代码 代码如下:$post=new Post;$post->title='samplepost';$post->conte...

php中session定期自动清理的方法

下文来为各位介绍PHP设置session定期自动清理的例子了,因为session默认是15分钟自动把变量给清除内存了,但有一些时间并不生效了,下面我们就来看看。 配置完成php后默认ph...

php连接oracle数据库及查询数据的方法

本文实例讲述了php连接oracle数据库及查询数据的方法。分享给大家供大家参考。具体分析如下: php有强大的功能不但可以支持mysql,mssql,mysqli之个我们还可以与ora...

PHP缓存机制Output Control详解

在php5.2版本的配置中,默认output_buffering为关闭状态,因此运行下面三行代码将会出现一个警告: Warning: Cannot modify header infor...