我们可以通过在程序的前后分别记录开始和结束时间,两个时间差就是程序的执行时间。
<?php $long_str = "this is a test to see how much time md5 function takes to execute over this string"; // start timing from here $start = microtime(true); // function to test $md5 = md5($long_str); $elapsed = microtime(true) - $start; echo "That took $elapsed seconds.\n"; ?>