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绘制在图片上的正余弦曲线

以前用actionscript写动态绘制三角函数曲线,其实php输出三角函数曲线也很简单。复制代码 代码如下:<?php define("MAX_WIDTH_PIXEL"...

php页面缓存ob系列函数介绍

这里有缓存技术的简单介绍:https://www.jb51.net/article/4965.htm   php页面缓存主要用到的是ob系列函数,如ob_start(),ob_end_f...

php Undefined index的问题

可以再错误语句前加上@ 也可以修改PHP.INI PHP.INI里的error_reporting = E_ALL造成的,如果不希望看到这个提示,可以 error_report...

PHP echo,print,printf,sprintf函数之间的区别与用法详解

1. echo函数: 输出函数,是命令,不能返回值。echo后面可以跟很多个参数,之间用分号隔开,如: echo $myvar1; echo 1,2,$myvar,"<b>b...

php实现递归与无限分类的方法

本文实例讲述了php实现递归与无限分类的方法,分享给大家供大家参考。具体实现方法如下: <?php echo "<pre>"; $area = array...