in reply to Re: Regex, capturing variables vs. speed
in thread Regex, capturing variables vs. speed
Giving the following results:use Benchmark qw/cmpthese/; my $line = 'rs11502186 C/G Chr11 170472 + ncbi_b34 perlegen urn:lsid:p +erlegen.hapmap.org:Protocol:Genotyping_1.0.0:2 urn:lsid:perlegen.hapm +ap.org:Assay:25763.7541533:1 urn:lsid:dcc.hapmap.org:Panel:CEPH-30-tr +ios:1 QC+ GG GG GG NN GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG + GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG NN + GG GG GG NN GG GG GG GG GG GG GG GG GG GG GG GG GG NN GG GG GG GG NN + GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG GG + GG GG GG GG GG GG'; cmpthese(-1, { 'Greedy' => sub {$line =~ /(chr.*?)\s.*urn:lsid:(.*?)\s.*p +anel:(.*?):/i}, 'Non' => sub {$line =~ /(chr.*?)\s.*?urn:lsid:(.*?)\s.*?pa +nel:(.*?):/i}, 'Sep' => sub {$line =~ /(chr.*?)\s/i; $line =~ /urn:lsid:(.*?)\s/i; $line =~ /panel:(.*?):/i; }, 'Death_star' => sub {$line =~ /(chr[^\s]+)/i; $line =~ /urn:lsid:([^\s]+)/i; $line =~ /panel:([^:]+)/i; } } );
Killing the star is clearly the way to go. Thanks to the Monks which helped me learn something.Rate Greedy Sep Non Death_star Greedy 8650/s -- -95% -95% -97% Sep 157827/s 1725% -- -6% -41% Non 167020/s 1831% 6% -- -38% Death_star 267963/s 2998% 70% 60% --
-albert
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex, capturing variables vs. speed
by robin (Chaplain) on Oct 30, 2005 at 20:31 UTC | |
by albert (Monk) on Oct 30, 2005 at 21:06 UTC | |
|
Re^3: Regex, capturing variables vs. speed
by GrandFather (Saint) on Oct 30, 2005 at 23:42 UTC |