SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: Creation time
Hybrid View
-
Oct 3, 2001, 22:08 #1
Creation time
On the bottom of polkaudio.com's website it gives you the time in seconds it took to create the website, I thought this was pretty cool and was wondering how to re-create the effect.
-
Oct 3, 2001, 22:17 #2
- Join Date
- Sep 2001
- Location
- Singapore
- Posts
- 5,269
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
it show the creation time thru a function in php... the site's done using php and the creation time is probably the execution/parsing time of the php script used to created the html file you see...
phpBB forums have this feature built in... check this out: http://phpbb.sourceforge.net/phpBB/ scroll right to the bottom and you'll see a message like
"phpBB Created this page in 0.141029 seconds."
as to how to implement it, i'll leave it to the experts...
-
Oct 3, 2001, 22:50 #3
I know it was created with php and I knew phpbb had it as well, what I'm wondering is if the time is a global variable or something, or did they run a function that acutally timed the creation of the page, and then spat out a number. i.e. does php keep track of page creation times or did they makeup a function.
-
Oct 3, 2001, 23:05 #4
- Join Date
- Jun 2000
- Location
- Yeppoon, Australia
- Posts
- 186
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The examples and information for the PHP microtime() function (at http://www.php.net/manual/en/function.microtime.php) give you all that you need to do this.
Basically you grab a timestamp at the very start of the page, do the processing, grab another timestamp and the difference between the two (nicely formatted) is the page generation time. There are code examples there.Knowledge is knowing that a tomatoe is a fruit; wisdom is not putting it in a fruit salad.
-
Oct 3, 2001, 23:06 #5
- Join Date
- Sep 2001
- Location
- Singapore
- Posts
- 5,269
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
printf("<center><font size=-2>phpBB Created this page in %f seconds.</font></center>", $totaltime);
-
Oct 3, 2001, 23:31 #6
hey cool! I knew it had to be a php function.
-
Oct 4, 2001, 11:52 #7
How would I do this over the course of an entire page?
Originally posted by redemption
PHP Code:$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
printf("<center><font size=-2>phpBB Created this page in %f seconds.</font></center>", $totaltime);
PHP Code:$mtime = microtime();
//Put all of my page code in here
dbconnect()
laksjdfl
laskdjf
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
printf("<center><font size=-2>phpBB Created this page in %f seconds.</font></center>", $totaltime);
-
Oct 4, 2001, 16:21 #8
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hers how I do it.
PHP Code:<?
//At top of script
$stime = microtime();
//Body
for($i=0;$i<10;$i++) {
print "$i";
}
print "<br>";
//At bottom of script
$etime = microtime();
$stime = explode(" ", $stime);
$etime = explode(" ", $etime);
$stime = $stime[0] + $stime[1];
$etime = $etime[0] + $etime[1];
print $etime - $stime;
?>
The reason for the addition is microtime rerturns a string with the microseconds a space then the regualr seconds. So you need to add the two toegther then subtract the number from the start and from the end.Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Oct 4, 2001, 17:27 #9
hey cool thanks, btw, when do you become a mentor
-
Oct 4, 2001, 17:34 #10
any idea on how to incorporate this into vbulletin's templates? I don't get this ob_get_contents() thing.
-
Oct 4, 2001, 21:38 #11
- Join Date
- Apr 2001
- Location
- My Computer
- Posts
- 2,808
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Snoozy
hey cool thanks, btw, when do you become a mentor
I guess Wayne or one of the other admins has to make you a mentor.
-
Oct 5, 2001, 12:52 #12Originally posted by Defender1
I guess Wayne or one of the other admins has to make you a mentor.
SeanHarry Potter
-- You lived inside my world so softly
-- Protected only by the kindness of your nature
Bookmarks