Re: Strange performance problem inside POE
Jan Sundberg <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
I found out the reason for the bad performance. It was due to the
use:age of Switch. It seems the Switch module has a severe impact on
regexp matching in genenaral and on /\G.../gc constructs in particular,
sometimes more than 30 times slower. Must be something with the source
filters use by Switch.
As soon as I removed use Switch and reconstructed my switch statement my
program became about 50 times faster!
NB: this had nothing to do with POE at all. It can also be me using an
old perl release 5.8.X.
Attached is an interlaced SmallProf listing between the two cases.
Switch maintainer is notified. Thanks to you people who came up with
ideas how to solve my problem.
FAST: 0 0.00000 0.00000 24:sub dict {
SLOW: 0 0.00000 0.00000 24:sub dict {
FAST: 853 0.00037 0.01000 25: ${$_[0]} =~ /\G\{/gc;
SLOW: 853 0.36373 0.36000 25: ${$_[0]} =~ /\G\{/gc;
FAST: 853 0.00162 0.03000 26: my $h = {};
SLOW: 853 0.00240 0.02000 26: my $h = {};
FAST: 853 0.00501 0.03000 27: while (${$_[0]} =~
SLOW: 853 0.35299 0.47000 27: while (${$_[0]} =~
FAST: 10053 0.01812 0.20000 28: my $key = $1;
SLOW: 10053 0.04336 0.23000 28: my $key = $1;
FAST: 10053 0.01980 0.20000 29: if (${$_[0]} =~ /\G(?=\{)/gc) {
SLOW: 10053 4.28763 4.32000 29: if (${$_[0]} =~ /\G(?=\{)/gc) {
FAST: 0 0.00000 0.00000 30: $h->{$key} = dict($_[0]);
SLOW: 0 0.00000 0.00000 30: $h->{$key} = dict($_[0]);
FAST: 0 0.00000 0.00000 32: } elsif (${$_[0]} =~
/\G([^\|\}]*)/gc) {
SLOW: 0 0.00000 0.00000 32: } elsif (${$_[0]} =~
/\G([^\|\}]*)/gc) {
FAST: 9201 0.01001 0.14000 33: my $value = $1;
SLOW: 9201 0.02721 0.16000 33: my $value = $1;
FAST: 9201 0.02044 0.17000 34: $h->{$key} = $value;
SLOW: 9201 0.02051 0.17000 34: $h->{$key} = $value;
FAST: 0 0.00000 0.00000 36: }
SLOW: 0 0.00000 0.00000 36: }
FAST: 10053 0.01922 0.12000 37: return $h if ${$_[0]} =~
/\G\}/gc;
SLOW: 10053 0.38550 0.48000 37: return $h if ${$_[0]} =~
/\G\}/gc;
FAST: 9200 0.05767 0.22000 38: ${$_[0]} =~ /\G\|/gc;
SLOW: 9200 7.62619 7.54000 38: ${$_[0]} =~ /\G\|/gc;
FAST: 0 0.00000 0.00000 39: }
SLOW: 0 0.00000 0.00000 39: }
FAST: 0 0.00000 0.00000 40:}
FAST: 0 0.00000 0.00000 40:}
Jan Sundberg skrev:
> Hello.
>
> I'm writing a regexp based parser based on the perlop manpage
> /\G.../gc example:
>
>
>
>