Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

How to add a sub that can show forum load time?

(Page 1 of 2)
> >
Quote Reply
How to add a sub that can show forum load time?
I like to show the forum load time at the end of forum, How to make it?
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
Hi backdream,

You'll need to install the Time::HiRes module in order to do this - otherwise the best you can get is whole seconds - and even if you see "1 second" it could be anywhere from 0.00001 seconds to 1.999999 seconds. Hence, doing this without Time::HiRes is almost pointless.

You'll need to make the changes in gforum.cgi (I've done this from time to time for development/optimization purposes). Basically, add this line immediately after all the "use" statements in the file:

Code:
use Time::HiRes;


Then add this line immediately after "sub main {":

Code:
$GForum::Start::Time = Time::HiRes::time();


After that, you're going to have to add a global - called "time_elapsed", perhaps. Its contents will be:

Code:
sub { $GForum::Start::Time - Time::HiRes::time() }


Then, wherever you want to display the time, just put:

Code:
Time to load: <%time_elapsed%> s

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] How to add a sub that can show forum load time? In reply to
Thank you, It's run fine.

but the time_elapsed sub maybe this:

Code:
sub {Time::HiRes::time() - $GForum::Start::Time }
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
I try it on my forum(PIII Xeon 700+1G Ram+U3 SCSI, Win2K+Apache+modperl+MySql), but the time_elapsed is average 4s per page. How about others Gforum ?
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
I am getting times of about 0.05 seconds, and the hardware specs are about the same as yours. OS is Linux, though.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
4s under modperl?! Your server must be heavily overloaded by other things, there is no way it should take that long. On a forum this size on a win2k, amd700, 512 megs of ram, and using MSSQL 2000, it averages 0.25s per page.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] How to add a sub that can show forum load time? In reply to
But why on my server so slow. On my server ,I use IIS for ASP and Perl for text, Use Apache + Mod_Perl for the Forum. When I see that a perl.exe running, it always cause the CPU usage up to 100%.
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
Hi,

Are you sure it's running under mod_perl? Add a global:

sub { $ENV{GATEWAY_INTERFACE} }

and tell me what it says?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] How to add a sub that can show forum load time? In reply to
It shows "CGI/1.1". It seems the mod_perl not worked...But the apache load ,it shows:

Code:
Preloading Gossamer Forum modules into mod_perl:
. . . . . . . . . . .
All modules loaded ok!
Compiling all functions ... All modules compiled and loaded ok!


I am attaching the httpd.conf, and startup.pl, Please notice me what's wrong!

My perl install in d:\perl, Apache install in d:\apache, My Gforum install in d:\sxforum.

Last edited by:

backdream: Nov 3, 2002, 4:11 PM
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
Quote:
<Location d:/sxforum>

That should be a URL without the domain name, not a path.
Quote Reply
Re: [Paul] How to add a sub that can show forum load time? In reply to
Now shows "CGI-Perl/1.1".

But when I make this change, All the images in d:/sxforum/images folder cannot locate and show.

Last edited by:

backdream: Nov 3, 2002, 8:51 PM
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
Yes because you have set that directory for mod_perl scripts. Move the images folder elsewhere.
Quote Reply
Re: [Paul] How to add a sub that can show forum load time? In reply to
Do you means set a alias? I move it to d:\images,and make a alias below:

Code:
Alias /images/ "D:/images/"<Directory "D:/images">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
But it cannot show images the same.
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
And when I set to '/', It cannot find the directoryindex I defined, and can only locate the cgi file.
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
Hi backdream,

You're going to need to change the image_url and image_path in GForum in order for it to recognize the new path. The image_url is easy - just change the variable.

As for setting the image_path, take a look at this post:

http://www.gossamer-threads.com/...i?post=221461#221461

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [backdream] How to add a sub that can show forum load time? In reply to
If you are going to leave the Time to Load message there all the time, you might use this sub for the global variable time_elapsed

sub { sprintf("%.2f", Time::HiRes::time() - $GForum::Start::Time) }

Cool

----------
Michael J. Challis - CRUZN8R - PT Cruiser Club - http://www.ptcruiserclub.org

http://www.ptcruiserclub.org/forum
Quote Reply
Re: [Jagerman] How to add a sub that can show forum load time? In reply to
Hi Jason,

I put the variable <%time_elapsed%> in include_footer.html and also in include_header.html. I get around 0,40s in include_header.html and around 1.50s in include_footer.html for the same page. Is it normal that I get two different times in the same page? If so, it meens that the place where we put the variable in the template changes his output. Unsure

Thank you.

François
Quote Reply
Re: [Franco] How to add a sub that can show forum load time? In reply to
I expect the time is different because the footer takes longer to load than the header as it is at the bottom of the page.
Quote Reply
Re: [Franco] How to add a sub that can show forum load time? In reply to
Various template calls and globals run throughout the page, so the difference you see is the amount of time to get through everything in the template. There is usually nothing intensive after include_footer.html, so that time is the usually the best one to go by.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Paul] How to add a sub that can show forum load time? In reply to
Hi:

I added this- thanks! I get a result like:

This Page Loaded In: 0.71395206451416 seconds

How can I trim this to 0.71... ?
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] How to add a sub that can show forum load time? In reply to
See post 16.
Quote Reply
Re: [Paul] How to add a sub that can show forum load time? In reply to
Paul:

Thanks.... (I was not familiar with that command, so I did not know!)
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] How to add a sub that can show forum load time? In reply to
%.2f will round to two decimal places. Just change 2 to whatever you require, eg...

%.0f = no decimal places
%.3f = 3 decimal places.
Quote Reply
Re: [Paul] How to add a sub that can show forum load time? In reply to
For some reason, with the upgrade to 1.20, I get an error with this now...

Cannot find subroutine &Time::HiRes::time...
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] How to add a sub that can show forum load time? In reply to
See the second post in the thread - your gforum.cgi would have been overwritten in the upgrade, so you'll need to make those two small modifications again.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
> >