Home > Backend Development > PHP Tutorial > Check the class of php code running time

Check the class of php code running time

WBOY
Release: 2016-07-25 09:03:28
Original
914 people have browsed it
  1. /**

  2. * Function: View the running time of php code
  3. * Date: 2012-12-29
  4. * File: show_php_runtime.php
  5. **/

  6. class RunTime//Page execution time class

  7. {
  8. private $starttime;// Page start execution time
  9. private $stoptime;//Page end execution time
  10. private $spendtime;//Page execution time spent
  11. function getmicrotime()//Get the floating point number that returns the current microseconds
  12. {
  13. list($usec, $sec)=explode(" ",microtime());
  14. return ((float)$usec + (float)$sec);
  15. }
  16. function start()//The page starts executing the function and returns the time when the page execution starts
  17. {
  18. $this->starttime=$this->getmicrotime();
  19. }
  20. function end()//Display the time of page execution
  21. {
  22. $this->stoptime=$this->getmicrotime( );
  23. $this->spendtime=$this->stoptime-$this->starttime;
  24. //return round($this->spendtime,10);
  25. }
  26. function display()
  27. {
  28. //$this->end();
  29. echo "

    Running time:".round($this->spendtime,10)."Seconds

    ";
  30. }
  31. }< /p>
  32. /*

  33. Call method
  34. */
  35. $timer=new Runtime();
  36. $timer->start();
  37. ?>

Copy code


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template