PHP code to calculate code running time and memory usage
WBOYOriginal
2016-07-25 09:00:38915browse
//Start timing
$HeaderTime = microtime(true);//The parameter true means returning a floating point value
//Code
//...
printf(" total run: %.2f s ".
"memory usage: %.2f M ",
microtime(true) -$HeaderTime,
memory_get_usage() / 1024 / 1024 );
?>
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