PHP program execution time detection
We sometimes need to judge the execution time and execution efficiency of the program.
The implementation ideas are as follows:
But don’t forget that the program runs too fast. It's as fast as a moment of only 0.00000 seconds. At this time, everyone has to record a special function:
mixed microtime ([ bool $get_as_float ] )
microtime() This function can return the current Unix timestamp and microseconds.
Parameters:
If you pass in true, a floating point type time will be returned, which is convenient for participating in operations.
Let’s simulate an example of detecting the execution time of a function to test the efficiency of a certain function:
The final output result is the execution time of our actual function. You can compare several times to see the final result.
Whoever has less time can use which function frequently in actual work.