We often need to do when some execution time of the program execution efficiency judgment. Marble platform test procedures
Ideas to achieve the following:
<?php // record start time // When the entire record junction // start time minus (-) end time to get the program running time ?>
But we should not forget, program speed too fast. Only the moment is coming 0.00000 seconds. This time we have to record that a special function of the letter:
mixed microtime ([ bool $get_as_float ] )
microtime, and () function, to return current Unix timestamp microseconds.
Parameters:
If you pass true, it will return a floating-point type of time, so easy to participate in operations.
Let's simulate an example of a detection function execution time, a function test of the efficiency of speed:
<?php //Starting time $time_start = microtime(true); // Loop ten thousand times for($i = 0 ; $i < 10000 ; $i++){ // you can spend, mktime () generates a time yesterday // then strtotime () generates a time yesterday Comparative // two functions efficiently recognized } // knot of all time $time_end = microtime(true); // obtained by subtracting the running time $time = $time_end - $time_start; echo "This script execution time was $ time seconds \ n"; ?>
Last output is the execution time of our actual function. You can compare more than a few times to see the final result.
Whose time is short, in the actual work, which often function you can use.