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

相关文章

浅析Apache中RewriteCond规则参数的详细介绍

RewriteCond就像我们程序中的if语句一样,表示如果符合某个或某几个条件则执行RewriteCond下面紧邻的RewriteRule语句,这就是RewriteCond最原始、基础...

php 如何获取数组第一个值

reset (PHP 3, PHP 4, PHP 5)reset -- 将数组的内部指针指向第一个单元 说明mixed reset ( array &array )reset() 将 a...

帝国cms目录结构分享

/ 系统根目录 ├d/          附件和数据存放目录 (data) │├file/ &n...

在windows平台上构建自己的PHP实现方法(仅适用于php5.2)

构建步骤1, 安装vs20082, 安装windows sdk 6.13, 下载php 5.2源码,可以从此处获取Releases (先不要解压)4, 下载bindlib_w32.zip...

通过table标签,PHP输出EXCEL的实现方法

通过table标签,PHP输出EXCEL的实现方法

关键代码:复制代码 代码如下:<?php header("Content-type:application/vnd.ms-excel"); header("Co...