Jump to content
xisto Community
Albus Dumbledore

Page Generation Time Script A script to tell how long it took to generate

Recommended Posts

this is a script used to tell you or visitors how fast your page was generated for the person who is viewing it...

 

Ok it is verry simple!! all you have to do is put this script on every page... that you want it to be on

 

<?php$starttime = explode(' ', microtime());$starttime = $starttime[1] + $starttime[0];?>

and put it before everything on the page, for me i put it right underneith the DOCTYPE script which i think is a bloody waste of space to have it on there, but anyways.. i put it right below that and it works fine!!

 

now where you want the time it took for the page to load to show put this script, generally at the bottom of the page, i put it at the evrry end right before the </html> tag

 

<?php$mtime = explode(' ', microtime());$totaltime = $mtime[0] + $mtime[1] - $starttime;printf('Page loaded in %.3f seconds.', $totaltime);?>

you can center that, put a box around it and all that change the text of what it shows wether it shows Page Generated in.... or if it says somthing else simply edit the stuff in bold here

 

<?php

 

$mtime = explode(' ', microtime());

$totaltime = $mtime[0] + $mtime[1] - $starttime;

printf('Page loaded in %.3f seconds.', $totaltime);

 

?>


ALSO, please note that the page you are putting this code on should be a .php oage because it is a php script that it is being used
Edited by Albus Dumbledore (see edit history)

Share this post


Link to post
Share on other sites

Hi, I think you're actually wrong. The script doesn't tell how fast the page loads for each visitor, but how fast the page is generated. "Page loaded in 0.371 seconds" would be very fast, and I would love that the internet was that fast. But I think it's the time the page is generated in. Correct me if i'm wrong :( Anyway, thanks for the code, it might be useful, and I may use it :(

Share this post


Link to post
Share on other sites

buffalo >_< the //////////thanxwas ment to be a thanks for whoever edits it lol oo well... guess i could have specified that... and thanx for clarifying that it must be a .php file, i guess i forgot that :-D

Edited by Albus Dumbledore (see edit history)

Share this post


Link to post
Share on other sites

I think this is the time it takes for the page to generate, not load. After all, the php is purely server side, and once the page is generated by the server it cannot report back (unless you tell it to with a seperate frame and using javascript perhaps). After the page is generated, it is sent to the user where the user needs to download it, including all images, and the server cannot know the user's connection speed, etc. Still, an interesting script that would be cool to develop on with javascript (onload) so that it truly shows the loading time.

Share this post


Link to post
Share on other sites

yeah, that was said a few times before >_< but now that ive been told by a few people i edited the post to say that it does not show how long it took to load, but acculy how long it took to generate..thanx every1

Share this post


Link to post
Share on other sites

it basicly tells you how long it took the server to generate the page that the user is viewing...and how it works is i dunno, i believe it pings the server and however long it takes to respond it posts it there...and i do not think it will delay your page any longer than it allready does..it jsut depends on what the script has to do

Share this post


Link to post
Share on other sites

The time() function in php measures the time of the server clock in relationship to the Linux epoch on Jan 1, 1970 at midnight ( I think ) using whole seconds. The microtime() function in php measures time for that that same starting point in time (Jan 1, 1970 at 12:00:00 A.M. GMT) (like the time() function) except the seconds are listed in smaller units and whole seconds also.

So, this first part of the script assigns a starting time of the page generation to a variable named $starttime and the ending time is calculated and stored into a variable named $mtime. The difference is the amount of time that it took to generate the page on the server.

Note that php5 has a different handling of this microtime() function. Refer to the php.net web site for the specifics. http://php.net/ and search for the microtime function there for the particulars.

Xisto is running php version 4.4.1 (not php5). There are some differences between versions for this function. Using php4 or earlier, it is required that the seconds and microseconds be 'exploded'. Using php5, it is not neccesary to 'explode' the microseconds. See the manual or refer to the php site per above. there is a listing of a technique to get php4 to work exactly as php5.

Share this post


Link to post
Share on other sites

This script could be very nice to integrate into certain php based systems. I might consider including this on something I have planned out, although I guess it could work on forum pages. I'm sure there are lots of other things it could be placed upon.

Share this post


Link to post
Share on other sites

please provide me with a link and i could look at the source and see if there is somthing wrong with it there..are you sure your page is saved as .php and not .html?

Share this post


Link to post
Share on other sites

You can view a testpage of it at: http://forums.xisto.com/no_longer_exists/

 

Notice from BuffaloHELP:
Please provide the source code.

 

Code According to Internet Explorer:

 

 

<html>

<head>

 

 

<!-- YOUR WEBSITE TITLE -->

<title>Home</title>

 

 

<link rel="stylesheet" type="text/css" href="styles.css">

</head>

 

<body topmargin="0" leftmargin="0" bgcolor="#DFFFFC"><center>

<table width="750" border="0" cellpadding="0" cellspacing="0">

<tr><td background="barleft.jpg" width="24" height="24"></td>

<td background="bar.jpg" width="703" height="24">

 

<p align="center"><font color="#FFFFFF" size="2" face="Verdana">

<span style="text-decoration: none; font-weight: 700">Zaccy Network & OzChat</span></font></td>

<td background="barright.jpg" width="23" height="24"></td></tr>

<tr><td background="barleft.jpg" width="24"></td>

<td width="703"><table width="703" border="0" cellpadding="0" cellspacing="0">

<tr><td valign="top" width="149">

 

<font face="Verdana">

 

 

<!-- HERE GOES THE NAVIGATION ! -->

</font>

<table border="0" cellpadding="0" cellspacing="0" width="93">

<tr><td background="menu.jpg" width="85" height="24" class="title">

<font face="Verdana">Navigation</font></td></tr>

<tr><td background="menuback.jpg" width="93">

<table align="left" border="0" cellpadding="4" cellspacing="0" width="92"><tr><td align="left">

<table border="0" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="138">

<tr><td align="center"><font color="#0000FF" face="Verdana" size="2">

<span style="font-weight: 400"><a href="http://forums.xisto.com/no_longer_exists/;

<span style="text-decoration: none">Home</span></a></span></font></td></tr>

<tr><td align="center"><font color="#0000FF" face="Verdana" size="2">

<span style="font-weight: 400">

<a href="http://forums.xisto.com/no_longer_exists/chat.html;

<span style="text-decoration: none">Chat</span></a></span></font></td></tr>

<tr><td align="center"><font color="#0000FF" face="Verdana" size="2">

<span style="font-weight: 400"><a href="http://forums.xisto.com/no_longer_exists/forum;

<span style="text-decoration: none">Forum</span></a></span></font></td></tr>

<tr><td align="center"><font color="#0000FF" face="Verdana" size="2">

<span style="font-weight: 400">Contact Us</span></font></td></tr>

</table>

</td></tr></table>

</td></tr>

<tr><td bgcolor="#000000" width="93" height="1"></td></tr>

</table>

<font face="Verdana">

<br>

 </font><table border="0" cellpadding="0" cellspacing="0" width="146">

<tr>

<td background="menu.jpg" width="138" height="24" class="title">

<font face="Verdana">Member Panel</font></td>

</tr>

<tr><td background="menuback.jpg" width="146">

<table align="left" border="0" cellpadding="4" cellspacing="0" width="145"><tr><td align="left">

<table border="0" bordercolor="#000000" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="130">

<tr><td class="text">

<form>

<p align="center"><font face="Verdana">Username:<br />

<input type="text" name="username" size="15"><br />

Password:<br />

<input type="text" name="username" size="15"><br />

<input type="submit" value="Login" name="submit">

<br>

<br>

<b><font color="#FF0000">Area Under Construction</font></b></font></p>

</form>

</td></tr>

</table>

</td></tr></table>

</td></tr>

<tr><td bgcolor="#DFFFFC" width="146" height="25"></td></tr>

</table>

<font face="Verdana">

<table bgcolor="#ffffff" width="148" id="table13">

<tr><td nowrap="nowrap" valign="top" align="center" height="32">

<a href="https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl;

<img src="http://forums.xisto.com/no_longer_exists/Logo_25wht.gif; border="0" alt="Google" align="middle" width="72" height="32"></img></a>

<br/>

<input type="text" name="q" size="14" maxlength="255" value=""></input>

</td></tr>

<tr><td valign="top" align="center">

<input type="submit" name="sa" value="Search Now"></input>

</input>

</input>

</input>

</input>

</input>

</input>

</td></tr></table>

<!-- HERE ENDS THE LOGIN PANEL ! -->

 

 

</font>

 

 

</td><td width="13" height="100%" bgcolor="#DFFFFC"> </td>

<td width="382" valign="top">

<table border="0" cellpadding="0" cellspacing="0" width="94%">

 

 

<!-- HERE GOES THE SHORT DESCRIPTION -->

<tr><td background="menu2.jpg" height="24" width="94%" class="title">

<font face="Verdana">Welcome</font></td></tr><tr><td width="96%">

<table border="1" cellpadding="4" cellspacing="0" bordercolor="#FF6600" bgcolor="#FFDBA6" style="border-collapse: collapse" width="100%"><tr>

<td width="87%" class="text">

 

<p align="center"><font face="Verdana">Hello there! I would like to take this

short moment to welcome you to the Zaccy Network and OzChat.<br>

<br>

</font><font face="Verdana" size="2">Due to circumstances beyond our control it

appears that we have lost the former Website. The reason for this is unknown.

The matter is currently being investigated and there was no backup of this site.

So a new site is currently being created and will be available as soon as

possible. We are sorry for any problems that this has caused our visitors and

team.<br>

 </font></td></tr></table></td></tr>

<tr><td height="16" bgcolor="#DFFFFC"> </td></tr>

<!-- THE SHORT DESCRIPTION BOX ENDS HERE -->

 

 

<!-- HERE GOES THE SOME FEATURES BOX -->

<tr><td background="menu2.jpg" height="24" width="94%" class="title">

<font face="Verdana"><font color="#0000FF">NEW</font> Update</font></td></tr><tr><td width="96%"><table border="1" cellpadding="4" cellspacing="0" bordercolor="#FF6600" bgcolor="#FFDBA6" style="border-collapse: collapse" width="100%"><tr><td width="100%" class="text">

 

<p align="center"><font face="Verdana" size="2">Our Chat Server and Forums are

back in full swing after a few minor problems. Everything is back running

smoothly. If you have any problems you can contact us on the link to the left of

this page.<br>

</font><font style="font-size: 8pt" face="Verdana"><br>

Posted By: Admin on 17 March

2006 at 3.19PM AEST</font></td></tr></table></td></tr>

<tr>

<td height="16" bgcolor="#DFFFFC"></td>

</tr>

<tr>

<td background="menu2.jpg" height="24" width="94%" class="title">

<font face="Verdana">Web Host Info. </font>

</td>

</tr>

<tr>

<td width="96%">

<table border="1" cellpadding="4" cellspacing="0" bordercolor="#FF6600" bgcolor="#FFDBA6" style="border-collapse: collapse" width="100%" id="table14"><tr><td width="100%" class="text">

 

<p align="center"><font face="Verdana" size="2">We are proud to announce that

our Site is now Hosted by AussieHQ. This is an Australian Web Hosting Company

dedicated to it clients.<br>

<br>

<img border="0" src="ahsmall02.jpg" width="75" height="27"><br>

<br>

</font><font style="font-size: 8pt" face="Verdana">Posted By: Admin on 12 March

2006 at 4.25PM AEST</font></td></tr></table></td>

</tr>

<tr><td height="7" bgcolor="#DFFFFC"></td></tr>

<!-- HERE ENDS THE SOME FEATURES BOX -->

 

</table>

</td>

<td width="160" height="100%" valign="top" bgcolor="#DFFFFC">

 

 

<table border="0" cellpadding="0" cellspacing="0" width="160" id="table7">

<!-- SPONSORED LINKS STARTS -->

<tr><td background="menu.jpg" width="160" height="24" align="center" class="title">

<p align="left">

<font face="Verdana">Sponsors </font>

</td></tr><tr><td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table8"><tr><td width="160" align="center">

<font face="Verdana" size="2" color="#FF0000">Information currently not

available.</font></td></tr></table></td></tr><tr><td bgcolor="#000000" width="160" height="1"></td></tr>

<tr><td height="24"></td></tr>

<!-- SPONSORED LINKS ENDS HERE -->

 

 

<!-- ADDITIONAL LINKS STARTS -->

<tr><td background="menu2right.jpg" width="160" height="24" align="center" class="title">

<p align="left">

<font face="Verdana">Additional Links

</font>

</td></tr><tr><td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table9"><tr><td width="160" align="center">

<font face="Verdana" size="2" color="#800080"><a href="https://www.google.de/?gfe_rd=cr&ei=BwkjVKfAD8uH8QfckIGgCQ&gws_rd=ssl;

<span style="text-decoration: none">Google</span></a><br>

<a href="http://yahoo.com/ style="text-decoration: none">Yahoo</span></a></font></td></tr></table></td></tr><tr><td bgcolor="#000000" width="160" height="1"></td></tr>

<tr>

<td height="24"></td>

</tr>

<tr>

<td background="menu2right.jpg" width="160" height="24" align="center" class="title">

<p align="left">

<font face="Verdana">Site Stats</font></td>

</tr>

<tr>

<td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table10"><tr><td width="160" align="center">

<b><font face="Verdana" size="2">Online Since</font></b><font color="#ff0000" face="Verdana" size="2"><br>

</font><font color="#800080" face="Verdana" size="2">12 March 2006<br>

4.00PM AEST</font></td></tr></table></td>

</tr>

<tr>

<td bgcolor="#000000" width="160" height="1"></td>

</tr>

<tr>

<td height="24"></td>

</tr>

<tr>

<td background="menu2right.jpg" width="160" height="24" align="left" class="title">

<font face="Verdana">Chat Server Status </font>

</td>

</tr>

<tr>

<td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table12"><tr><td width="160" align="center">

<font face="Verdana" size="2"><b>Date:</b> <script type="text/javascript">

var d = new Date()

document.write(d.getDate())

document.write(".")

document.write(d.getMonth() + 1)

document.write(".")

document.write(d.getFullYear())

</script><br>

<font color="#FF0000"><b>ONLINE</b></font></font></td></tr></table></td>

</tr>

<tr>

<td bgcolor="#000000" width="160" height="1"></td>

</tr>

<tr>

<td height="24"></td>

</tr>

<tr>

<td background="menu2right.jpg" width="160" height="24" align="center" class="title">

<p align="left">

<font face="Verdana">Hit Counter</font></td>

</tr>

<tr>

<td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table11"><tr><td width="160" align="center">

<font size="2" face="Verdana"><b>

<i>

<img src="http://www.supercounters.com/counter.php?id=118592;

border="0" alt="free web counter"></i></b></font></td></tr></table></td>

</tr>

<tr>

<td bgcolor="#000000" width="160" height="1"></td>

</tr>

<!-- ADDITIONAL LINKS ENDS HERE -->

</table>

 

 

<table border="0" cellpadding="0" cellspacing="0" width="160" id="table17">

<tr>

<td height="24"></td>

</tr>

<tr>

<td background="menu2right.jpg" width="160" height="24" align="center" class="title">

<p align="left">

<font face="Verdana">Other Info.</font></td>

</tr>

<tr>

<td background="menuback2.jpg" width="160">

<table border="0" cellpadding="4" cellspacing="0" width="160" id="table18"><tr><td width="160" align="center">

<font face="Verdana" size="2"><b>Best View</b><br>

800 x 600 Screen Res.<br>

with Internet Explorer</font></td></tr></table></td>

</tr>

<tr>

<td bgcolor="#000000" width="160" height="1"></td>

</tr>

<!-- ADDITIONAL LINKS ENDS HERE -->

</table>

 

 

</td></tr></table></td><td background="barright.jpg" width="23"></td></tr><tr>

<td width="24" height="24" background="barleft.jpg"></td>

<td width="703" height="24" bgcolor="#DFFFFC"> </td>

<td width="23" height="24" background="barright.jpg"></td></tr><tr>

<td width="24" height="24" background="footer.jpg"></td>

<td width="703" height="24" background="footer.jpg" class="copyright" align="center">

 

 

<!-- THE COPYRIGHT -->

©Copyright 2005 - 2006 - Zaccy Network & OzChat</td>

<td width="23" height="24" background="footer.jpg"></td></tr>

</table></center>

Page loaded in 0.000 seconds.</body>

</html>

<p><br>

</p>

<p><br>

</p>

 

 

Edited by BuffaloHELP (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.