How to calculate function execution time in php, php calculate function execution_PHP tutorial

WBOY
Release: 2016-07-13 10:02:02
Original
825 people have browsed it

How PHP calculates function execution time, PHP calculates function execution

The example in this article describes how PHP calculates function execution time. 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.
Copy code 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/970988.htmlTechArticleHow to calculate function execution time in PHP, PHP calculates function execution time. The example in this article describes how PHP calculates function execution time. Share it with everyone for your reference. The details are as follows: We can...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template