>  기사  >  백엔드 개발  >  PHP 计算页面执行时间

PHP 计算页面执行时间

WBOY
WBOY원래의
2016-07-25 09:01:45924검색
自己写了个计算页面执行时间的脚本
执行时间会显示在页面右上角
优点是只要在开始的时候执行一下就可以了
  1. $t = new executeTime;
  2. phpinfo();
  3. class executeTime{
  4. private $microtime;
  5. public function __construct(){
  6. $this->microtime = microtime(true);
  7. }
  8. public function getNow(){
  9. $this->__dectruct();
  10. }
  11. public function __destruct(){
  12. if (empty($_SERVER['REQUEST_TIME_FLOAT']))
  13. echo '
    本次执行时间:', microtime(TRUE) - $this->microtime, '秒
    ';
  14. else
  15. echo '
    本次执行时间:', microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], '秒
    ';
  16. }
  17. }
复制代码


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.