From: [EMAIL PROTECTED]
> Ok, so to clarify then the use of the grouping operator /(.)/ imposes
> the penalty, not the $1 reference to the grouped data?
Exactly.
use Benchmark;
$string = 'sdfg q3wgrasdga wiufeg
alidsugfqlweifbzxlvubqlirewhfaskdjhqlwrefblakncvbalewrugfksjdhgfkywabe
kjhsbcvjyagemrjyfbnbcvuytwaevlfasudg,bzsdkvybqlwerugfwelrbvxcjhvbs8erg
lkjashdv lufhdsagliuaehwrlfbasydgfesrug';
sub without {
my $s = $string;
$s =~ s/dsug/A/g;
}
sub with {
my $s = $string;
$s =~ s/(dsug)/A/g;
}
timethese 1000000, {
without => \&without,
with => \&with,
}
Benchmark: timing 1000000 iterations of with, without...
with: 8 wallclock secs ( 7.21 usr + 0.00 sys = 7.21 CPU)
@ 138696.26/s (n=1000000)
without: 5 wallclock secs ( 4.26 usr + 0.00 sys = 4.26 CPU)
@ 234962.41/s (n=1000000)
Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs