计算运行时间及内存使用,代码如下:
<?php //开始计时 $HeaderTime = microtime(true);//参数true表示返回浮点数值 //代码 //... printf(" total run: %.2f s<br>". "memory usage: %.2f M<br> ", microtime(true)-$HeaderTime, memory_get_usage() / 1024 / 1024 ); ?>
结果:
total runtime: 1.47 s
memory usage: 77.09 M