php计算函数执行时间的方法_PHP教程

WBOY
Release: 2016-07-13 10:01:17
Original
1290 people have browsed it

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

 这篇文章主要介绍了php计算函数执行时间的方法,以md5函数加密运行时间为例分析了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程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/971951.htmlTechArticlephp计算函数执行时间的方法 这篇文章主要介绍了php计算函数执行时间的方法,以md5函数加密运行时间为例分析了php计算函数运行时间的技巧...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!