in reply to Re: Re: speeding up regex
in thread speeding up regex
You could try replacing
with$count++ while $text =~ /$gene/g; # Count number of instances
$count = () = $text =~ /$gene/g;
It may run a little quicker. You could also try
my $p=0; ++$count while $p = 1+index( $text, $gene, $p );
Which may be quicker still.
If your process takes a long time to run, the obvious thing to do to save having to wait for the whole thing to complete before you can get a feel for which is quickest would be too use a small subset of the data whilst testing. If the text being search comes from a file, try using head to grab the first couple of hundred lines of the real data and use that for performance testing the options.
|
|---|