Hi All,
I did a quick benchmark test on his code using non
threaded 5.8.0 and 5.6.1 and indeed there is
a serious performance degradation.
It is the combination of the i and the g regex modifiers
that causes the performance issue. If you remove one of them
the performance is the sames as in 5.6.1.
I did't not dig deeper into this, but there must be an explanation for this.
ps:
this is the code I used
#!/usr/local/bin/perl5.8.0 or #!/usr/local/bin/perl5.6.1
use Benchmark;
$main::x=join("",(a..z))x100;
&timethis(100,\&test);
sub test {
$main::x =~ s/(.*?)I/$1/isge;
}
update On popular demand, here are the benchmark results.
Perl 5.8.0
timethis 1000: 48 wallclock secs (46.76 usr + 0.02 sys = 46.78 CPU) @
+ 21.38/s (n=1000)
Perl 5.6.1
timethis 1000: 1 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU) @
+ 1428.57/s (n=1000)
When debugging with
use re "debug", there are some differences (I only post the last few lines)
In 5.8.0, it gives
Setting an EVAL scope, savestack=12
24 <opqrstuvwx> <yz> | 1: OPEN1
24 <opqrstuvwx> <yz> | 3: MINMOD
24 <opqrstuvwx> <yz> | 4: STAR
Setting an EVAL scope, savestack=12
failed...
Setting an EVAL scope, savestack=12
25 <opqrstuvwxy> <z> | 1: OPEN1
25 <opqrstuvwxy> <z> | 3: MINMOD
25 <opqrstuvwxy> <z> | 4: STAR
Setting an EVAL scope, savestack=12
failed...
Setting an EVAL scope, savestack=12
26 <opqrstuvwxyz> <> | 1: OPEN1
26 <opqrstuvwxyz> <> | 3: MINMOD
26 <opqrstuvwxyz> <> | 4: STAR
Setting an EVAL scope, savestack=12
failed...
Match failed
whilst in 5.6.1, it returns
SANY can match 1 times out of 1...
23 <opqrstuvw> <xyz> | 6: CLOSE1
23 <opqrstuvw> <xyz> | 8: EXACTF <I>
failed...
SANY can match 1 times out of 1...
24 <opqrstuvwx> <yz> | 6: CLOSE1
24 <opqrstuvwx> <yz> | 8: EXACTF <I>
failed...
SANY can match 1 times out of 1...
25 <opqrstuvwxy> <z> | 6: CLOSE1
25 <opqrstuvwxy> <z> | 8: EXACTF <I>
failed...
SANY can match 1 times out of 1...
26 <opqrstuvwxyz> <> | 6: CLOSE1
26 <opqrstuvwxyz> <> | 8: EXACTF <I>
failed...
SANY can match 0 times out of 1...
failed...
Match failed
But, since I am not a regex expert, I have no clue what this means :-)
---------------------------
Dr. Mark Ceulemans
Senior Consultant
BMC, Belgium