To record the code execution time in the page in php, we only use the microtime function to generate the time, and then subtract the start and end time at the end to solve the problem.
Core Code
The code is as follows | |||||
// ...execute code ... $t2 = microtime(true); echo 'Time consuming'.round($t2-$t1,3).'Seconds';
|
代码如下 | |
|
The code is as follows | |
$start_time=microtime(true); //Get the time when the program starts executing echo "hello world! "; //The code you execute $end_time=microtime(true);//Get the time when program execution ends $total=$end_time-$start_time; //Calculate the difference echo "The code in this php file was executed for {$total} seconds"; ?>
|