Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Inexplicably slow regex

by duff (Parson)
on Sep 12, 2006 at 18:15 UTC ( [id://572591]=note: print w/replies, xml ) Need Help??


in reply to Inexplicably slow regex

I don't have an answer to your question but could you show your benchmarks for those regular expressions?

Replies are listed 'Best First'.
Re^2: Inexplicably slow regex
by hgolden (Pilgrim) on Sep 12, 2006 at 18:26 UTC
    I'd also be interested in seeing the benchmarks. I can add one thing: the last Regex isn't the same as the others because the [^\n] character class is (accidently) a negated character class. Rearranging it to [\n^] should fix that.

    Hays

      Nothing accidental about the negation of that character class. I'm using it with a negative look-behind assertion. It's supposed to mean: "If it's not true that the preceding character is not a linebreak". So it's either a linebreak or there's nothing there at all (beginning of string).

      Processing a file approximately 0.5MB in size, using gettimeofday for timing, I get
      First version: 0.7 seconds
      Second version: 0.003 seconds
      Third version: 0.03 seconds

      My actual regexes are slightly more complicated than the examples given so I see little speed difference between #2 and #3.
        You may wish to show your actual regex, as that's the likely source of the issue.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2025-06-14 08:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.