in reply to how to speed up pattern match between two files
Well you're doing a lot of work, searching though a large array for each entry in another large array.
but there are a few things you can try.
You don't need to extract the positions unless it's a line your interested in, so swap the order of those tests :-
foreach $line (@data) { if ( $line =~ /$one/ && $line =~ /$two/ ) { if ( $line =~ /(.*?)\s+(.*?)\s+(.*?)\s+(.*)+/ ) { $chr = $1; $pos1 = $2; $pos2 = $3; } ... } }
Try using index instead of a regex to match $one & $two, it's usually quicker.
if (index($line,$one) != -1 && index($line,$two) != -1) { ... }
Profile your code to find out where the time is going, and measure the difference each change makes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to speed up pattern match between two files
by gnujsa (Acolyte) on Sep 17, 2014 at 07:38 UTC | |
by RichardK (Parson) on Sep 17, 2014 at 09:15 UTC | |
by gnujsa (Acolyte) on Sep 17, 2014 at 15:58 UTC | |
|
Re^2: how to speed up pattern match between two files
by Anonymous Monk on Sep 16, 2014 at 19:25 UTC | |
by ww (Archbishop) on Sep 17, 2014 at 22:46 UTC |