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

相关文章

浅析application/x-www-form-urlencoded和multipart/form-data的区别

在Form元素的语法中,EncType表明提交数据的格式 用 Enctype 属性指定将数据回发到服务器时浏览器使用的编码类型。 下边是说明: application/x-www-for...

php natsort内核函数浅析第1/2页

官方手册(http://us.php.net/manual/en/function.natsort.php)复制代码 代码如下:bool natsort ( array &$array...

php源码的安装方法和实例

在官网下载源码包:https://www.php.net/downloads.php 步骤: 1、解压 命令:tar -xjvf php.tar.bz2 2、configure conf...

简单谈谈php浮点数精确运算

bc是Binary Calculator的缩写。bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_operand,...

php实现留言板功能(代码详解)

php实现留言板功能(代码详解)

简单的PHP留言板制作 做基础的留言板功能  需要三张表: 员工表,留言表,好友表 首先造一个登入页面: <form action="drcl.php" metho...