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();

相关文章

php5中date()得出的时间为什么不是当前时间的解决方法

相关设置是修改php.ini中的 date.timezone 参数: [Date] ; Defines the default ...

PHP中的正则表达式函数介绍

正则表达式(Regular Expression) 正则表达式系统:   1.POSIX   2.Perl PHP中使用的regex是PCRE:   NOTE:PCRE(Perl兼容正则...

PHP数组式访问接口ArrayAccess用法分析

本文实例讲述了PHP数组式访问接口ArrayAccess用法。分享给大家供大家参考,具体如下: PHP  ArrayAccess接口又叫数组式访问接口,该接口的作用是提供像访问...

php join函数应用

复制代码 代码如下: $key = array(); $val = array(); foreach ($_POST as $k=>$v) { $key[] = '`'.strip...

使ecshop模板中可引用常量的实现方法

比如$smarty.const.'常量',这个就不能用。 其实模板引擎原理上并不复杂,只是把一些模板标签替换为php中的函数,变量,语法结构罢了。 这次要在ecshop模板中加入引用常量...