>  기사  >  php教程  >  php计算函数执行时间的方法,php计算函数执行

php计算函数执行时间的方法,php计算函数执行

WBOY
WBOY원래의
2016-06-13 09:10:421170검색

php计算函数执行时间的方法,php计算函数执行

本文实例讲述了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";
?>

运行结果如下:

That took 7.1525573730469E-6 seconds.

希望本文所述对大家的php程序设计有所帮助。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.