PHP Code Snippet: Page Load Speed Test Generated Script
php code snippet: page load speed test generated script
php, code, snippet, page, load, speed, test, generated, script
PHP Code Snippet: Page Load Speed Test Generated Script
Post Description: php code snippet: page load speed test generated script
POST# 1052
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: PHP Code Snippet: Page Load Speed Test Generated Script
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
Share:
BBCODE:
HTML Code:


Tue Jul 17, 2007 5:31 pm
1
adrian
Reply #1774
nice script you have here! :d

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload