PHP 计算页面执行时间
来源:互联网 发布:淘宝买进口保健品 编辑:程序博客网 时间:2024/04/29 19:51
$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 style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:'
, microtime(TRUE) -
$this
->microtime,
'秒</div>'
;
19
else
20
echo
'<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:'
, microtime(TRUE) -
$_SERVER
[
'REQUEST_TIME_FLOAT'
],
'秒</div>'
;
21
}
22
}