Home >Backend Development >PHP Tutorial >A function that calculates the running time of a php page

A function that calculates the running time of a php page

WBOY
WBOYOriginal
2016-07-25 09:07:21724browse
  1. /*

  2. Calculate php program running time
  3. */
  4. function microtime_float()
  5. {
  6. list($usec, $sec) = explode(" ", microtime( ));
  7. return ((float)$usec + (float)$sec);
  8. }

  9. //Start timing and put it on the head

  10. $starttime = microtime_float();
  11. / /End the timer and put it at the bottom
  12. $runtime = number_format((microtime_float() – $starttime), 4).'s';
  13. //Output
  14. echo 'RunTime:'.$runtime;
  15. ?>< /p>
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