Questions tagged «microtime»

9
如何基准测试PHP脚本的效率
我想知道什么是基准测试我的PHP脚本的最佳方法。cron作业,网页或Web服务无关紧要。 我知道我可以使用microtime,但这真的给了我PHP脚本的实时性吗? 我想测试和比较PHP中执行相同功能的不同函数。例如,preg_matchvs strpos或domdocumentvs preg_match或preg_replace vs str_replace` 网页示例: <?php // login.php $start_time = microtime(TRUE); session_start(); // do all my logic etc... $end_time = microtime(TRUE); echo $end_time - $start_time; 这将输出:0.0146126717(一直在变化-但这是我得到的最后一个)。这意味着执行PHP脚本大约需要0.015。 有没有更好的办法?

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.