PHP Code Snippet: Page Load Speed Test Generated Script



PHP Code Snippet: Page Load Speed Test Generated Script
 (381) dminister a web business
PHP Code Snippet: Page Load Speed Test Generated Script
Post Description:
Post Tags: php, code, snippet, page, load, speed, test, generated, script
This Post Has Been Viewed 3055 Times Since Fri Jul 28, 2006 9:14 am Posted By hostman with 2 replies
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

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About PHP Code Snippet: Page Load Speed Test Generated Script




:: 1 :: #11311 - Reply By adrian On Tue Jul 17, 2007 5:31 pm
nice script you have here! :d
:: 2 :: #51940 - Reply By camilord On Mon Apr 28, 2008 9:44 am
hehehehe.. i already have this script. but i always forgot to save in my hdd.. hehehehe.. anyway, thanks again...