自己寫了個計算頁面執行時間的腳本
執行時間會顯示在頁面右上角
優點是只要在開始的時候執行一下就可以了
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 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
}