Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: very slow processing

by philipbailey (Deacon)
on Aug 20, 2014 at 19:23 UTC ( #1098148=note: print w/replies, xml ) Need Help??


in reply to very slow processing

My eye is drawn to this:

    $line =~ /\[(.+?)\] .* \[(.+?)\] .* \[[^]]+\] \s+ (.*) /x or next ;

It seems to me that the repeated .* is likely to result in a lot of backtracking during the match of the regex. I suggest you try replacing the first two .* expressions with something like [^\[]+ and add a $ anchor at the end. That would change that line to:

    $line =~ /\[(.+?)\] [^\[]+ \[(.+?)\] [^\[]+ \[[^]]+\] \s+ (.*)$ /x or next ;

There may be something more elegant you could do (and somebody will chip in) but I bet that will result in a speed improvement.

Mind you, the O n^2 algorithm won't help.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1098148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2022-01-25 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (67 votes). Check out past polls.

    Notices?