Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Question : Lots of globals, or a main plugin?

Quote Reply
Question : Lots of globals, or a main plugin?
Hi,

Just a performance question really =)

I'm contemplating setting up a lot of our "global" routines in a plugin. This would just give a way to access things with: <%Plugins::AndysGlobals::global_name()%>, rather than just <%global_name()%>.

My question, is would this be any better, or slower in terms of loading the page?

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Question : Lots of globals, or a main plugin? In reply to
It won't make any difference I imagine. A global function such as:

sub { return ... }

...is just the same as:

Plugins::Andy::xyz

...except the former is anonymous. Both need to be compiled either way. The only performance hit would be loading the module for the first time.

A little trick to speed things up is to do....

Code:
use GT::AutoLoader;

$COMPILE{my_function} = __LINE__ . <<COMPILE;
sub my_function {
#------------------------------------------------------------------------
# This function will be compiled on demand.

...

}
COMPILE

Last edited by:

Hargreaves: Dec 5, 2005, 9:58 AM
Quote Reply
Re: [Hargreaves] Question : Lots of globals, or a main plugin? In reply to
Hi,

True, but what about mod_perl? ATM, the templates arn't compiled into mod_perl, but the .pm files are... so surely there would be a difference there?

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Question : Lots of globals, or a main plugin? In reply to
You would need to load your plugin module into mod_perl by either editing mod_perl.pm or the startup.pl file so that each time the mod_perl server is restarted your module(s) would load into memory, but as not everyone uses mod_perl then only those people will benefit.
Quote Reply
Re: [Hargreaves] Question : Lots of globals, or a main plugin? In reply to
In Reply To:
You would need to load your plugin module into mod_perl by either editing mod_perl.pm or the startup.pl file so that each time the mod_perl server is restarted your module(s) would load into memory

Yeah, that's what I thought.

Quote:
but as not everyone uses mod_perl then only those people will benefit.

Its not for my plugins, but just some of my own "larger" sites, that I'm trying to optimize= )

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!