Home >Backend Development >PHP Tutorial >PHP calculate page execution time

PHP calculate page execution time

WBOY
WBOYOriginal
2016-07-25 09:01:45972browse
I wrote a script to calculate the page execution time
The execution time will be displayed in the upper right corner of the page
The advantage is that you only need to execute it at the beginning
  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 '< div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">This execution time:', microtime(TRUE) - $this-> ;microtime, 'seconds
';
  • else
  • echo '
    This execution time:', microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], 'Seconds
    ';
  • }
  • }
  • Copy code


    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn