function xn_start(){
global $xn_start_time;
global $xn_start_memory;
/**
* 代码性能测试代码
*/
$xn_start_memory = memory_get_usage(); //开始内存
$xn_start_time = microtime(true);
}
function xn_end(){
global $xn_start_time;
global $xn_start_memory;
echo '开始内存:' . $xn_start_memory . '<br>';
$end_time = microtime(true); //获取程序执行结束的时间
$run_time = ($end_time - $xn_start_time); //计算差值 秒
echo "[页面执行时间:{$run_time}]秒<br>";
$end_memory = memory_get_usage();
echo '运行后内存:'. $end_memory . '<br>';
echo '使用的内存:' . ($end_memory - $xn_start_memory) . '<br>';
echo '回到正常内存:'.memory_get_usage();
die;
}
Use
performed at the beginning of the code xn_start ();
end of code execution xn_end ();
Output of content:
Memory start: 1153552
Seconds: [.02082896232605 Execution Time]
after running out of memory: 1344856
memory usage: 191 304
back to normal memory: 1344856