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

PHP code to calculate code running time and memory usage

WBOY
Release: 2016-07-25 09:00:38
Original
880 people have browsed it
  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



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