Home  >  Article  >  Backend Development  >  How to calculate function execution time in php_PHP tutorial

How to calculate function execution time in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:01:171340browse

How to calculate function execution time in PHP

This article mainly introduces the method of calculating function execution time in PHP. It takes the md5 function encryption running time as an example to analyze the PHP calculation function operation. For time skills, friends who need them can refer to them

The example in this article describes the method of calculating function execution time in PHP. Share it with everyone for your reference. The details are as follows:

We can record the start and end time before and after the program. The difference between the two times is the execution time of the program.

The code is as follows:

$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";
?>

The running results are as follows:

That took 7.1525573730469E-6 seconds.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/971951.htmlTechArticleHow to calculate function execution time in PHP This article mainly introduces the method of calculating function execution time in PHP, using the md5 function Encryption running time is used as an example to analyze PHP's techniques for calculating function running time...
Statement:
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