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.