- Forums
- Snippets
- PHP Code Snippet: Page Load Speed Test Generated Script
This Page Contains information about PHP Code Snippet: Page Load Speed Test Generated Script By wallpaperama in category Snippets with 6 Replies. [1368], Last Updated: Sat May 18, 2024
wallpaperama
Fri Jul 28, 2006
6 Comments
9750 Visits
Put the following code at the very beginning of your PHP page.
CODE:
<?
# Page Load Test Script by Webune.com
# http://www.webune.com/forums/
$load_time = microtime();
$load_time = explode(' ',$load_time);
$load_time = $load_time[1] + $load_time[0];
$page_start = $load_time;
?>
Now put the folowing code at the bottom of your page. I suggest you put it just right before the </body></html> TAGS..
CODE:
<?
$load_time = microtime();
$load_time = explode(' ',$load_time);
$load_time = $load_time[1] + $load_time[0];
$page_end = $load_time;
$final_time = ($page_end - $page_start);
$page_load_time = number_format($final_time, 4, '.', '');
echo("Page generated in " . $page_load_time . " seconds");
?>
That's it. Load you page and you will see a message at the bottom of the page telling you how long it takes for your web page to load. Look at the bottom of you page where it says: Page generated in xx.xx seconds
View Demo: http://www.webune.com/tutorials/page-load.php