Home > php教程 > php手册 > php计算函数执行时间的方法,php计算函数执行

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

WBOY
Release: 2016-06-13 09:10:42
Original
1218 people have browsed it

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程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template