想知道某个模块执行的时间,然后优化下;
PHP 中microtime()可以打印出微秒,便于计算脚本执行时间
// 开始计时 list($micro_start,$second_start)=explode(' ',microtime()); // 需要执行的代码模块 // 等待5000微妙,即5毫秒 usleep(5000); // 结束时间 list($micro_end,$second_end)=explode(' ',microtime()); // 换算毫秒,保留三位小数 $time=round((($second_end+$micro_end)-($second_start+$micro_start))*1000,3); echo $time.'ms';
Leave a Reply