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迭代与递归实现无限级分类

PHP迭代与递归实现无限级分类

无限级分类是开发中常见的情况,因此本文对常见的无限极分类算法进行总结归纳. 1.循环迭代实现 $arr = [ 1=>['id'=>1,'name'=>'父1'...

PHP pthread拓展使用和注意点

一. 线程的创建和使用1. Thread类基本的创建和使用:<?php //通过继承Thread类来实现自己的线程类MyThread class MyThrea...

ThinkPHP路由详解

有了基本配置,我们就可以来访问我们的应用默认首页了。进入到项目目录,可以直接使用PHP内置服务器来开始访问,比如: php -S localhost:8999 浏览器输入loc...

设置php页面编码的两种方法示例介绍

1:输出meta标签: 1、在php mvc的控制器里面或php页面echo '<meta http-equiv="content-type" content="text/html...

php中try catch捕获异常实例详解

本文实例讲述了php中try catch捕获异常。分享给大家供大家参考。具体方法分析如下: php中try catch可以帮助我们捕获程序代码的异常了,这样我们可以很好的处理一些不必要的...