It's obviously not new, but the January 2006 edition of MSDN Magazine has some useful performance tips, particularly in the area of Regular Expressions. File this under the category of 'things I talk about here so I can refer to them myself later'.
A few quick quote snippets:
In the Regular Expression (Regex) space, there is the option to specify that a regular expression is compiled through use of the RegexOptions.Compiled setting. This switch hints at an underlying aspect of regular expressions in .NET: they have three modes.
Interpreted Regexes have the smallest impact to the startup performance of an application, but they have the slowest run-time speed since all of the processing remains to be conducted at run time. They are a good option if your Regex will be used rarely, since a rarely used expression won't impact overall run-time speed much (by definition), and taking any kind of startup hit probably isn't worth it
Regex precompilation solves many of the problems associated with compiling on the fly, and retains all of the performance benefits. Precompilation means you do all of the work of parsing and generating MSIL when you compile your app, ending up with a custom class derived from Regex. Run-time performance of this technique is identical to what you get when you compile on the fly.
There is, of course, a trade-off: the whole meaning of precompiled is that the Regex is put into its own assembly before you run your application. You therefore can't have the code for constructing the Regex inline, and you'll have to write other code (a tool perhaps) to construct your precompiled Regex ahead of time.
It's worth a read if you use a lot of Regular Expression, and in particular if you've ever had to use them inside loops.
Link: Base Class Library Performance Tips and Tricks: Regular Expression Compilation
Tags:
ASP.NET