[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-developers] Use of globals

From: Daniel Tryba
Subject: [Phpgroupware-developers] Use of globals
Date: Mon, 4 Nov 2002 20:09:15 +0100
User-agent: Mutt/1.4i

Hmmmm, looking at phpgwapi/inc/ (trying to figure out why it
costs so much time[1] to include it), I noticed the strange use
of globals, eg:

function CreateObject($class,
   global $phpgw_info, $phpgw;

   if (is_object(@$GLOBALS['phpgw']->log) && $class != 'phpgwapi.error' && 
$class != 'phpgwapi.errorlog')

Why use the array $GLOBALS['phpgw']->log instead of $phpgw->log directly? 
The same for the use of the GLOBALS array after the function declarations, 
here the vars/objects are already "in scope".

Looking at the output of apcinfo.php for the it spends lots of
time playing with arrays/objects (don't have the actual info since the 
$&#*(^% machine crashed after office hours).

So what (if anyhting) am I missing? Might there be any performance gain by
switching to global $var instead of $GLOBAL[$var] [2], since this will
save some hash lookups?

[1] On my dev machine, a PIII 600 with 1Gb RAM running Linux, it takes about
0.35s to include / Testing a the page with ab (1000 requests
with 10 concurrent) it amounts to a performance of about 2.30 pagerequests per
second (yippie :). Installing APC and strippig lang() improves performance
to about 4 pr/s, only problem is I need about 30 pr/s (the production machine
will be a bit faster (maybe 3 times)). So anyone got any ideas how to improve
the performance?

[2] keeping in mind that unset($var) won't work on global $var

reply via email to

[Prev in Thread] Current Thread [Next in Thread]