Php function execution time calculation method
This article describes how to calculate the execution time of functions in php. The following uses md5 function encryption runtime as an example to analyze the php function execution time. For more information, see
This example describes how to calculate the function execution time in php. Share it with you for your reference. The details are as follows:
We can record the start time and end time respectively before and after the program. The two time differences are the execution time of the program.
The Code is as follows:
<? 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 ";
?>
The running result is as follows:
That took 7.1525573730469E-6 seconds.
I hope this article will help you with php programming.