Sometime, you may want to know exactly how long your web server did execute your PHP script. This example below will show you how to measure your execution time.
1. Put the following code at the very top of your PHP script
<?php $start_process = (float) array_sum(explode(' ',microtime())); ?> |
2. Put the following code at the very bottom of your PHP script
<?php $end_process = (float) array_sum(explode(' ',microtime())); echo "<!--Execution time: ". sprintf("%.4f", ($end_process-$start_process))." seconds" . "-->"; ?> |
So, your final PHP script looks like this:
<?php $start_process = (float) array_sum(explode(' ',microtime())); ?> //Your PHP scirpt here //Or your HTML code here <?php $end_process = (float) array_sum(explode(' ',microtime())); echo "<!--Execution time: ". sprintf("%.4f", ($end_process-$start_process))." seconds" . "-->"; ?> |