Joomla! Discussion Forums



It is currently Mon Mar 15, 2010 4:01 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 15 posts ] 
Author Message
Posted: Wed Nov 16, 2005 5:20 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
Is there a way to add the page generation time to the frontend.  At the bottom of every page when I'm logged into the backend I see a message like "Page was generated in 0.314618 seconds"

I'd like to have this done on pages in the frontend while I'm developing so I can see the effect of different components, modules, and bots and how changes in queries on my custom stuff changes the page generation time.

Thanks

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 5:34 pm 
Joomla! Guru
Joomla! Guru
Offline

Joined: Thu Sep 01, 2005 12:22 pm
Posts: 606
Didn't think this through, but if you put
$starttime = time();
in the beginning of your index.php and
$endtime = time();
near the end, and then show the difference, wouldn't you more or less be where you want?

Ludo


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 5:51 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon Nov 14, 2005 9:52 pm
Posts: 3
Interesting.

I tried it ludo... nothing happened.  :'(


Top
   
 
Posted: Wed Nov 16, 2005 5:53 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
Code:
<body>
<?php $starttime = time(); ?>


blah blah blah


Code:
<?php $endtime = time();
$pagetime = $endtime - $starttime;
echo $pagetime;?> <br>
<?php echo $endtime; ?> <br>
<?php echo $starttime; ?>
  </body>


tried this, and I get

1
1132163478
1132163477

at the bottom of the page

is time that seconds since 1972 value?  wanted something with a little more precision... ???

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 5:56 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
Also I wasn't quite sure where to put it relative to head and body?

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:01 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
OK
change to microtime() and you get time in microseconds now I have

0.182749
0.25116700 1132163988
0.06841800 1132163988

just a minute and I'll clean it up a little and add the this page was generated...

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:09 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
Hmm..
Maybe not
some of my pages are giving negative times???
Would be fantastic if it were true, but I suspect not??

Any other suggestions or point out where I've mucked it up??

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:24 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Wed Nov 16, 2005 6:20 pm
Posts: 1
stingrey over at http://www.stingrey.biz/ has at the bottom of the page something that says:
Quote:
Page loaded in 0.061 seconds.


Is this what you are asking? Might want to PM him about how he did it.


Top
   
 
Posted: Wed Nov 16, 2005 6:31 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Wed Aug 17, 2005 10:30 pm
Posts: 826
Location: Vienna, VA US
Near beginning of template's index.php file:

//  Start page load timer ...tick tock...
//  -----------
$tstart = mosProfiler::getmicrotime();
?>


Near end of template's index.php file:

//  Display page generation time...
//  ---------
$tend = mosProfiler::getmicrotime();
$totaltime = ($tend - $tstart);
printf ("Page was generated in %f seconds", $totaltime);
?>

_________________
If you need a helping hand, use the one at the end of your own arm.
www.hrpr.com


Top
   
 
Posted: Wed Nov 16, 2005 6:35 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
HitLines wrote:
stingrey over at http://www.stingrey.biz/ has at the bottom of the page something that says:
Quote:
Page loaded in 0.061 seconds.


Is this what you are asking? Might want to PM him about how he did it.


Yes this is what I want.  I'm sure Rey is using a cleaner way to do it, but I figured out what was wrong with the above.
microtime returns both the number of seconds since the UNIX epoch (1970 not '72...) and the number of microseconds separated by a space so you have to explode the string and put it back together as a float then do the subtraction.  The negative values came in when the seconds turned over...

This works.

After the body tag

Code:
<body>
<?php
function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

$time_start = microtime_float();
?>
<?php $starttime = 0; $starttime = microtime (); ?>


before the tag

Code:
<?php $time_end = microtime_float();
$time = $time_end - $time_start;
echo "This page was generated in $time seconds\n";?>
<br> start
<?php echo $time_start; ?>
<br> end
<?php echo $time_end; ?>
  </body>


Thanks for the start.

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:38 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
HarryB wrote:
Near beginning of template's index.php file:


Near end of template's index.php file:



This looks easier than what I kludged together...  :-[

What exactly do "Near beginning" and "Near end" mean? can I have one in the head, before the , after the anywhere I want...?

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:40 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
And while we're at it, any comment on what a reasonable value is, and when you'd want to start worrying?  Most of mine are coming in under 100 ms but about 10% are 100-300 ms.

How fast is fast and how slow is slow?

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Wed Nov 16, 2005 6:45 pm 
User avatar
Joomla! Ace
Joomla! Ace
Offline

Joined: Sun Aug 21, 2005 2:57 pm
Posts: 1366
Location: Colorado, USA
Hey they even agree if I run them simultaneously.

This page was generated in 0.096924066543579 seconds
start 1132166695.5053
end 1132166695.6022

HarryB version
Page was generated in 0.096996 seconds

_________________
¡Pura Vida!
Ray,
joomla in testing at Costa Rica Travel: http://costaricamap.net
http://costa-rica-guide.com


Top
  E-mail  
 
Posted: Thu Nov 17, 2005 1:36 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Wed Aug 17, 2005 10:30 pm
Posts: 826
Location: Vienna, VA US
rsphaeroides wrote:
HarryB wrote:
Near beginning of template's index.php file:


Near end of template's index.php file:



This looks easier than what I kludged together...  :-[

What exactly do "Near beginning" and "Near end" mean? can I have one in the head, before the , after the anywhere I want...?
I usually put it after the statement and right before the statement...

_________________
If you need a helping hand, use the one at the end of your own arm.
www.hrpr.com


Top
   
 
Posted: Thu Nov 17, 2005 1:48 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Wed Aug 17, 2005 10:30 pm
Posts: 826
Location: Vienna, VA US
rsphaeroides wrote:
And while we're at it, any comment on what a reasonable value is, and when you'd want to start worrying?  Most of mine are coming in under 100 ms but about 10% are 100-300 ms.

How fast is fast and how slow is slow?
Really defends on server environment, shared versus dedicated, CPU speed, memory size, number of concurrent users, tuning and optimization of OS, php, mysql, etc.  Personally, I consider anything under 1.0 second to be reasonable.

_________________
If you need a helping hand, use the one at the end of your own arm.
www.hrpr.com


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

Quick reply

 



Who is online

Users browsing this forum: tunit25 and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group