develooper Front page | perl.perl5.porters | Postings from February 2013

[perl #66762] Regex search time varies wildly with input

Thread Next
From:
Andrew Daviel via RT
Date:
February 27, 2013 21:51
Subject:
[perl #66762] Regex search time varies wildly with input
Message ID:
rt-3.6.HEAD-31961-1361922399-1308.66762-15-0@perl.org
I must have missed Bram's reply and then forgotten about this.

When I re-try my case #2 with Time::HiRes, now at least I get better
results from Perl 5.10 than from Perl 5.8

match                           Perl 5.8     5.10
/(.*[\d]+).*radon/               0.72 us     0.51 us
/(.*[\d]+).*radon/i           5345.95 us    48.1 us
/.*[\d]+.*radon/i               77.23 us    45.16 us
/.*[\d]+.*(?i:radon)/           55.63 us    45.06 us
/(.*[\d]+).* radon/i          5483.97 us    51.47 us
/(.*[\d]+).* (?i:radon)/      5285.52 us  4432.8 us
/(.*[\d]+).* foobar.* radon/  1428.14 us  1408.74 us
/(.*[\d]+).* foobar.* radon/i 4534.89 us    70.32 us

If I lowercase the input before matching, it's faster:
s/radon/radon/i ; /.*[\d]+.* radon/  1.61 us   1.72 us

I still find it hard to see which patterns are going to be slow


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=66762

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About