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

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

Thread Next
Andrew Daviel via RT
February 27, 2013 21:51
[perl #66762] Regex search time varies wildly with input
Message ID:
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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About