xoops forums

ZPC

Official Support Member
Posted on: 2002/2/20 19:01
ZPC
ZPC (Show more)
Official Support Member
Posts: 76
Since: 2002/1/16
#11

Re: This page loaded in x seconds

yes..it's not about the transfer of the page from the server to your browser, it's the time that took the server to parse all the php and sql command and print-out the output...

the time depends on things like server hardware (CPU, memory), operating system, apache+php+sql setup etc...

jasXoop

Just popping in
Posted on: 2003/10/2 5:54
jasXoop
jasXoop (Show more)
Just popping in
Posts: 22
Since: 2003/10/1
#12

Re: This page loaded in x seconds

Hi,
It is hard to figure out what needs to be uncommented out and where, before the load times could be displayed on a site. I am testing XOOPS version 2.03, and would like to enable this feature on the site. A posting of a piece of the code and the location would be very helpful.

Thanks in advance for your help.

Jas.

brash

Friend of XOOPS
Posted on: 2003/10/5 12:56
brash
brash (Show more)
Friend of XOOPS
Posts: 2206
Since: 2003/4/10
#13

Re: This page loaded in x seconds

I'm using 2.0.4 and would also appreciate a bit more detail on how to do this. I'm having a few performance issues, and I don't want to have to leave the debug mode on to get load time information.

brash

Friend of XOOPS
Posted on: 2003/10/5 23:04
brash
brash (Show more)
Friend of XOOPS
Posts: 2206
Since: 2003/4/10
#14

Re: This page loaded in x seconds

^bump^

Reason I'm asking about this is the line number references seem to be different to what's stated above for 2.0.4, and I don't know what I should be looking for as I'm a PHP noob.

brash

Friend of XOOPS
Posted on: 2003/10/6 6:05
brash
brash (Show more)
Friend of XOOPS
Posts: 2206
Since: 2003/4/10
#15

Re: This page loaded in x seconds

OK, I've done a bit of reading and searching, and I keep coming back to the /class/logger.php file for XOOPS 2.X based systems. I found an XOOPS doc at SourceForge which I think is relevant, and it refers to the dumpTime function. I also fount this in the /class/logger.php file which looks to me to be relevant, but then again I can barely spell PHP let alone code it.

Quote:

/**
* get the current execution time of a timer
*
* @param string $name name of the counter
* @return float current execution time of the counter
*/
function dumpTime($name = 'XOOPS')
{
if (!isset($this->logstart[$name])) {
return 0;
}
if (!isset($this->logend[$name])) {
$stop_time = explode(' ', microtime());
} else {
$stop_time = $this->logend[$name];
}
return ((float)$stop_time[1] + (float)$stop_time[0]) - ((float)$this->logstart[$name][1] + (float)$this->logstart[$name][0]);
}



Can anyone tell me if I'm going down the right track with this, or even better how to implement this into my footer?

Olorin

Just popping in
Posted on: 2003/10/6 14:06
Olorin
Olorin (Show more)
Just popping in
Posts: 50
Since: 2003/7/5 1
#16

Re: This page loaded in x seconds

First,insert the following code to your theme.html.
Quote:

<{php}>
global $ftime;
echo"This page is loaded in $ftime seconds.";
<{/php}>

Second,insert this code to your footer.php,line 30.
Quote:
$ftime=$xoopsLogger->dumpTime();

BEFORE
Quote:

$xoopsLogger->stopTime();
if ($xoopsOption['theme_use_smarty'] == 0) {

AFTER
Quote:

$xoopsLogger->stopTime();
$ftime=$xoopsLogger->dumpTime();
if ($xoopsOption['theme_use_smarty'] == 0) {

I think there is a smarter solution. But it works at very least.

brash

Friend of XOOPS
Posted on: 2003/10/7 1:20
brash
brash (Show more)
Friend of XOOPS
Posts: 2206
Since: 2003/4/10
#17

Re: This page loaded in x seconds

Thanks heaps for you help Olorin

I tried entering the code you posted into the theme.html file of the theme I am using (phpkaox), but nothing is printed to the screen (I placed it at the very bottom just before the </body> tag) . I also tried putting the code into the footer (as this is where I was wanting it anyway), and all it seems to do was print the entire code to screen. I tried making an adaption to suit my needs;

Quote:
This page loaded in <? php global $ftime; echo $ftime; ?> seconds


This prints correctly at in the footer, except the actual load time is absent as when I replace $ftime with text such as hello, the text is displayed, so I assume I'm missing something to get the $ftime value to print.

I also made the other code changes you specified. One thing I was wondering is what kicks off the time log? Would I have to include something like

Quote:
$xoopsLogger->startTime();


in the header.php to start the time logging process?

Thanks again

Olorin

Just popping in
Posted on: 2003/10/7 13:01
Olorin
Olorin (Show more)
Just popping in
Posts: 50
Since: 2003/7/5 1
#18

Re: This page loaded in x seconds

Quote:
This page loaded in <? php global $ftime; echo $ftime; ?> seconds

This cord doesn't work since your theme file is html.

Quote:
$xoopsLogger->startTime();

And this function is already called in common.php

Thus my code should work with XOOPS 2.0.x. At least,it's working at my site...
Did you update your cache?

OldSwede

Just popping in
Posted on: 2003/10/7 15:34
OldSwede
OldSwede (Show more)
Just popping in
Posts: 26
Since: 2003/8/15
#19

Re: This page loaded in x seconds

Thank you,

this works perfect for me with 2.0.4 and 2.0.5 RC

wr
oldswede

brash

Friend of XOOPS
Posted on: 2003/10/8 1:00
brash
brash (Show more)
Friend of XOOPS
Posts: 2206
Since: 2003/4/10
#20

Re: This page loaded in x seconds

Thanks so much Olorin ! I was wondering where the time logging was kicked off.

I've also managed to get the page load time displayed in the footer just as I wanted. I searched phpkaox theme.html for this bit of code;

Quote:
<{$xoops_footer}>


Then just added your code directly after this, with a <p> tag on the end to space it out a bit. So after I added the code it looked like this;

Quote:
<{$xoops_footer}><{php}>global $ftime;
echo"This page is loaded in $ftime seconds.";
<{/php}><p>


You can see what it looks like at www.it-hq.org

Once again, thank you so much Olorin!