I wrote a bit of code that I was concerned about the speed of. It looks
like:
return map {
my $x = $_;
$x =~ s/(?<!^)(')(?!$)/$1$1/g;
$x;
} @_;
So, I benchmarked it, and got:
Benchmark: timing 1000000 iterations of lookaround...
lookaround: 0 wallclock secs ( 0.48 usr + 0.00 sys = 0.48 CPU) @
2083333.33/s (n=1000000)
I thought the (?<!) and (?!) were expensive, since I need to stop, look
behind, look ahead, and then move on -- am I wrong? The actual
benchmarking code follows.
Cheers,
-Andrew
timethese(1000000, {
lookaround => q{
map {
my $x = $_;
$x =~ s/(?<!^)(')(?!$)/$1$1/g;
$x;
} @arr;
}
} );
Andrew Stanley
http://www.cs.uml.edu/~astanley/