Regex performance?

  • Thread starter Thread starter Beeeeeves
  • Start date Start date
B

Beeeeeves

Anyone have any ideas on how fast .NET regexes are when operating on large
amounts of text?
(the input could be, say, 10KB of text, the regex's pattern would be fairly
big ( getting on for 1KB perhaps, but non-too complex as 90% of that would
be just lots of words strung together)
particularly when using the MatchEvaluator delegate.

Thanks
 
There are statistical methods for finding a fixed string within a much larger
string
that allows you to jump over large amounts of text. In this single case a Regex
may perform more quickly than some other form of search over top of the string.

I will say that expressions are best at matching patterns, not at fixed
matching.
To state this properly expressions are a set of tools for specifying and
matching
unknown strings of a preset format. Because of the generality they often
sacrifice
speed, even when compiled.
 
Beeeeeves,

I haven't seen any numbers for when using the MatchEvaluator delegate,
but in general, using RegEx is fast (especially if you compile it, which you
can do through one of the settings).

When in doubt though, test. You seem to have all the information you
need to run some tests and produce the numbers (the performance, that is)
you need.

Hope this helps.
 
Yes, I think profiling's the way to go
Thanks

Nicholas Paldino said:
Beeeeeves,

I haven't seen any numbers for when using the MatchEvaluator delegate,
but in general, using RegEx is fast (especially if you compile it, which you
can do through one of the settings).

When in doubt though, test. You seem to have all the information you
need to run some tests and produce the numbers (the performance, that is)
you need.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Beeeeeves said:
Anyone have any ideas on how fast .NET regexes are when operating on large
amounts of text?
(the input could be, say, 10KB of text, the regex's pattern would be fairly
big ( getting on for 1KB perhaps, but non-too complex as 90% of that would
be just lots of words strung together)
particularly when using the MatchEvaluator delegate.

Thanks
 
Back
Top