Show Page Load Time In PHP

Show Page Load Time In PHP
Using a line of code at the beginning of the file and a function call at the end, you can count the number of milliseconds it took PHP to load the page.
function PerfStopCount()
        global $StartAt;
        $EndAt = time()+microtime();
        $TimeElapsed = round($EndAt - $StartAt,4);
        echo "Loaded in ".$TimeElapsed." milliseconds";
$StartAt = time() + microtime();
// The PHP code for the page has to go here (in the middle)
// Sample time consuming code
for($i = 0; $i < 100000; $i++)
        $i ^ 2;
// End sample

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top