httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: A-T: include resolution in httpd.conf
Date Wed, 19 Nov 2003 17:18:59 GMT
André Malo wrote:
> * Stas Bekman <stas@stason.org> wrote:
> 
> 
>>  $path =~ s/^\s*["']?|["']?\s*$//g;
> 
> 
> sounds reasonable.
> Doing this in two regexps instead of using the alternation is more efficient,
> however.

We probably don't care much about msecs during the config time ;) but I did 
run the benchmark nevertheless ;)

perl /tmp/bench
Benchmark: timing 500000 iterations of one, two...
        one: 35 wallclock secs (33.50 usr +  0.15 sys = 33.65 CPU) @ 
14858.84/s (n=500000)
        two: 26 wallclock secs (25.22 usr +  0.09 sys = 25.31 CPU) @ 
19755.04/s (n=500000)

So yes, it's faster to do 2 separate regexes ;)

use Benchmark qw(:all) ;

my @data = qw(
     "foo/bar/path/to/some/long/data/baz"
     foo/bar/path/to/some/long/data/baz
     foo/bar/baz
     'foo/bar/baz'
);

my $count = 500000;

timethese($count, {
                'one' => \&one,
                'two' => \&two,
});

sub one {
     my @copy = @data;
     for (@copy) {
         s/^\s*["']?|["']?\s*$//g;
     }
}

sub two {
     my @copy = @data;
     for (@copy) {
         s/^\s*["']?//;
         s/["']?\s*$//;
     }
}



__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message