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关联数组与索引数组及其显示方法

数据 username password test 123456 关联数组: mysql_fetch_assoc() array([username]=>'test...

PHP载入图像imagecreatefrom_gif_jpeg_png系列函数用法分析

本文实例分析了PHP载入图像imagecreatefrom_gif_jpeg_png系列函数用法。分享给大家供大家参考,具体如下: imagecreatefrom 系列函数用于从文件或...

php代码检查代理ip的有效性

本文实例为大家分享了检查代理ip有效性php代码,稳定性,如错误率和查询用时 /** +---------------------------------------------...

php switch语句多个值匹配同一代码块应用示例

先说说switch()语句的格式 switch(表达式){ case 匹配1: 当匹配1和表达式匹配成功执行的代码; break; case 匹配2: 当匹配2和表达式匹配成功执行的代码...

PHP的Yii框架中行为的定义与绑定方法讲解

定义行为 要定义行为,通过继承 yii\base\Behavior 或其子类来建立一个类。如: namespace app\components; use yii\base\Beh...