in reply to Algorithm To Select Lines Based On Attributes
Some quick thoughts:
#1: Use Devel::NYTProf or another profiler to see what the actual hot-spots in your code are!
Read lines from disk one at a time rather than slurping into @lines
Consider defining rules as subroutines acting on an argument and then use Memoize to cache results (assuming attributes re-occur frequently)
If you're re-running this against the same set of lines and rules frequently, cache the rule test results in a file or DB so you have DEFECTID and a list of rules it matches.
Perhaps reorganize the rules (if you can): $hash->{RULETYPE}->{RULENUMBER} = value. Then iterate the list of rules for each attribute, rather than (as you have it), iterating the attributes for each rule. I think that saves a lot of if ( defined $rulelist->{$rulenum}->{REGION} ) comparisons.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Algorithm To Select Lines Based On Attributes
by ~~David~~ (Hermit) on Jan 15, 2009 at 18:06 UTC | |
by xdg (Monsignor) on Jan 15, 2009 at 18:36 UTC |