perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <sbek...@stason.org>
Subject Re: cvs commit: modperl-2.0/lib/ModPerl Code.pm
Date Fri, 14 Apr 2000 16:39:40 GMT
On Fri, 14 Apr 2000, Bill Moseley wrote:

> At 11:56 AM 04/14/00 +0300, Stas Bekman wrote:
> >>   sticking to the convention of single quoting constant strings
> >
> >Why? You lose the interpolation feature when you need it and you get to
> >the awkward statement like this:
> >
> >>   -        print $h_fh "\n#define ",
> >>   +        print $h_fh "\n", '#define ',
> 
> Orwant and friends in "Algorithms with Perl" page 28 claims the first form
> is slower.

% perl -v
This is perl, version 5.005_03 built for i386-linux

xxx:
----
           use Benchmark;

           timethese(500000, {
               'My'   => sub {return "\n#define "},
               'Your' => sub {return "\n", '#define '},
           });

% perl xxx
Benchmark: timing 500000 iterations of My, Your...
        My:  7 wallclock secs ( 4.49 usr +  0.31 sys =  4.80 CPU)
      Your:  5 wallclock secs ( 4.40 usr +  0.34 sys =  4.74 CPU)

        My:  5 wallclock secs ( 4.40 usr +  0.34 sys =  4.74 CPU)
      Your:  6 wallclock secs ( 4.90 usr +  0.32 sys =  5.22 CPU)

        My:  7 wallclock secs ( 4.34 usr +  0.34 sys =  4.68 CPU)
      Your:  5 wallclock secs ( 4.55 usr +  0.32 sys =  4.87 CPU)


As you see not on my machine, unless print() behaves diffently... 
Apparently it's not: 

xxx1:
-----
           use Benchmark;

           open STDERR , ">>/dev/null";
           timethese(500000, {
               'My'   => sub {print STDERR "\n#define "},
               'Your' => sub {print STDERR "\n", '#define '},
           });


% perl xxx1
Benchmark: timing 500000 iterations of My, Your...
        My:  9 wallclock secs ( 7.56 usr +  0.54 sys =  8.10 CPU)
      Your: 13 wallclock secs ( 9.50 usr +  0.67 sys = 10.17 CPU)

        My: 11 wallclock secs ( 7.74 usr +  0.56 sys =  8.30 CPU)
      Your: 13 wallclock secs ( 9.73 usr +  0.60 sys = 10.33 CPU)

25% slower!!!

It seems that TIMTOWTDI is going to die soon as everybody tells me that I
should code as shown in "OO Perl" and ""Algorithms with Perl" :( 

The books are cool, but why turning them into bibles? The book authors are
great, but why rising them into gods? 

Every time I should post a snippet of code I'm afraid to be flamed for
writing a *bad* code :( I guess you saw some examples at the fun-with-perl
mailing list. 

______________________________________________________________________
Stas Bekman             | JAm_pH    --    Just Another mod_perl Hacker
http://stason.org/      | mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org  | http://perl.org    http://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
----------------------------------------------------------------------


Mime
View raw message