Reveal Sidebar

Go Back   YoungCoders Computer Programmers Forum > Programming > PHP Scripting > PHP Articles

PHP Articles Read and post PHP tutorials.

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-03-2004
Randi Randi is offline
A Toddler - Don't be Fooled!
 
Join Date: Sep 2004
Posts: 5
Rep Power: 0
Randi is on a distinguished road
page generation time

This tutorial will show you how to add a page generation time on your website. This is what we have to do:
1. Get the time in micro-seconds using the function: microtime().
2. Turn the micro-time into an array using the explode() function.
3. Add the two parts to the array together (the micro-seconds to the seconds).
4. Repeat steps 1,2 and 3 for the bottom of the page
5. Find the total loading time by taking the time taken at the end of the page from the time taken at the top of the page
6. Round the microtime and return it to the browser
Put at the top of your page:
PHP Code:
<?
 $m_time 
explode(" ",microtime()); 
 
$m_time $m_time[0] + $m_time[1]; 
 
$starttime $m_time;
?>
Put at the bottom of your page.

PHP Code:
<?
 $round 
3;// The number of decimal places to round the micro time to.
 
$m_time explode(" ",microtime()); 
 
$m_time $m_time[0] + $m_time[1]; 
 
$endtime $m_time
 
$totaltime = ($endtime $starttime); 
 echo 
"Page loading took:"round($totaltime,$round) ." seconds"
?>
Thats it. You should now have yourself a page generation time on your website!

This tutorial was taken from http://www.spoono.com
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
It is time to become a webhosting reseller wizard Articles, Tutorials, and Guides 0 01-07-2005 10:45 PM
Impressing Search Engines wizard Articles, Tutorials, and Guides 0 01-07-2005 10:44 PM
Writing Your First Page wizard HTML & CSS Articles 3 01-06-2005 05:40 AM
Go to another part of a document (on the same page)! Helloadam HTML & CSS Articles 0 09-18-2004 11:17 AM


All times are GMT -6. The time now is 11:38 PM.

Return to Top
Powered by mullac.org VM hosting.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2008, YoungCoders.com
Add to Technorati Favorites