The need to recompile the three patterns each time through the outer loop is probably what's taking extra time. You could compile them once with qr, @patterns = map qr/\Q$_\E/, @patterns; or test lines of interest with index, since the patterns seem to be constant,
I think the fastest way is to avoid the inner loop and gain the speed of hash lookup like this:foreach my $pattern (@patterns) { if (-1 != index $line, $pattern) { push(@events, $line); last; } }
That solution depends on there being no other content in the @$srcRef lines, besides the chomped line ends.chomp @$srcRef; my %pattern; @pattern{@patterns} = (); my @events = grep {exists $pattern{$_}} @$srcRef;
After Compline,
Zaxo
In reply to Re: performance explanation needed
by Zaxo
in thread performance explanation needed
by yoganaut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |