Home  >  Article  >  Backend Development  >  PHP code to calculate code running time and memory usage

PHP code to calculate code running time and memory usage

WBOY
WBOYOriginal
2016-07-25 09:00:38808browse
  1. //Start timing

  2. $HeaderTime = microtime(true);//The parameter true means returning a floating point value

  3. //Code

  4. //...

  5. printf(" total run: %.2f s
    ".

  6. "memory usage: %.2f M
    ",
  7. microtime(true) -$HeaderTime,
  8. memory_get_usage() / 1024 / 1024 );
  9. ?>

Copy code

Output results: total runtime: 1.47 s memory usage: 77.09 M



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