On Tue, 26 Dec 2000, Ken Williams wrote:
> [EMAIL PROTECTED] (Stas Bekman) wrote:
> >A combination of C<strict> and C<vars> pragmas keeps modules clean and
> >reduces a bit of noise. However, the C<vars> pragma also creates
> >aliases, as does C<Exporter>, which eat up more memory. When
> >possible, try to use fully qualified names instead of C<use vars>.
>
> I have to disagree with this benchmark. The aliases take up only the
> tiniest bit of memory, much less than your benchmark seems to indicate.
> What your benchmark shows is the code size of the 'vars.pm' module
> itself, not the memory cost of making aliases.
Nothing like a good peer review :) Thanks Ken. I was wondering myself
about this cool save up.
$owed_beers{ken}++
You must come to ApacheCon or TPC to reset this counter, though :)
-------
Here is a corrected version:
package MyPackage1;
use strict;
use vars; # added only for fair comparison
@MyPackage1::ISA = qw(CGI);
$MyPackage1::VERSION = "1.00";
1;
instead of:
package MyPackage2;
use strict;
use vars qw(@ISA $VERSION);
@ISA = qw(CGI);
$VERSION = "1.00";
1;
Here are the numbers under Perl version 5.6.0
% perl -MGTop -MMyPackage1 -le 'print GTop->new->proc_mem($$)->size'
2023424
% perl -MGTop -MMyPackage2 -le 'print GTop->new->proc_mem($$)->size'
2031616
We have a difference of 8192 bytes.
Note that Perl 5.6.0 introduced a new our() pragma which works like
my() scope-wise, but declares global variables.
package MyPackage3;
use strict;
use vars; # added only for fair comparison
our @ISA = qw(CGI);
our $VERSION = "1.00";
1;
which uses the same amount of memory as a fully qualified global
variable:
% perl -MGTop -MMyPackage3 -le 'print GTop->new->proc_mem($$)->size'
2023424
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/