PHP计算页面执行时间源代码

2013 年 3 月 29 日3700

PHP计算页面执行时间源代码

Builder开发者在线 来源: 中国IT实验室 2013年03月28日

关键词: php

本文摘要

PHP计算页面执行时间,执行时间会显示在页面右上角,优点是只要在开始的时候执行一下就可以了。

Builder开发者在线 PHP 计算页面执行时间,执行时间会显示在页面右上角,优点是只要在开始的时候执行一下就可以了。

自己写了个计算页面执行时间的脚本

执行时间会显示在页面右上角

优点是只要在开始的时候执行一下就可以了

代码片段(1)[代码] [PHP]代码

01 <?php

02 $t = new executeTime;

03

04 phpinfo();

05

06 class executeTime{

07 private $microtime;

08 public function __construct(){

09 $this->microtime = microtime(true);

10 }

11

12 public function getNow(){

13 $this->__dectruct();

14 }

15

16 public function __destruct(){

17 if (empty($_SERVER['REQUEST_TIME_FLOAT']))

18 echo '<div>本次执行时间:', microtime(TRUE) - $this->microtime, '秒</div>';

19 else

20 echo '<div>本次执行时间:', microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], '秒</div>';

21 }

22 }

本文导航

转发

本文关键词: php

文章评论

登录 (没有帐户?快速注册)

使用第三方帐号登录:

0 0