In this script, I will show you how to get the execution time of a script an to display it.
This script is very simple, we will get the micro-seconds in the beginning and in the and of the script using the microtime function of PHP. Then, we will do a subtraction to get the elapsed time during the script execution.
This is the code to use:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<?php
function timer()
{
$time = explode(' ', microtime());
return $time[0]+$time[1];
}
$beginning = timer();
?>
<html>
<!-- The content of your page -->
Page generated in <?php echo round(timer()-$beginning,6); ?> seconds.
</body>
</html>
0 comments:
Post a Comment