Last year, these benchmark results became hot points of contention between Java and .NET developers. What the results suggested was that Java regular expression engines are significantly faster than .NET's Regex.
I thought it might be fun to port one of the fastest Java regular expression engines to J# and see how it performs compared to .NET's Regex. I chose the dk.brics.automaton engine because it seemed easiest to port. It was. When I ran a straight-forward C# port of regtest.java on the J# version of dk.brics.automaton and compiled singleline Regex, I got these results:
| dk.brics.automaton | 2303 milliseconds |
| Regex | 2894 milliseconds |
I also ran regtest.java on the original dk.brics.automaton and Java's built-in regular expression engine. Results were:
| dk.brics.automaton | 511 milliseconds |
| java.util.regex | 1061 milliseconds |
While J# version of dk.brics.automaton's performance is muffled by J#, I think Regex's relatively slow performance should not be blamed entirely on its implementation.
IMHO, .NET performance is 'good enough' for server-side use at this time so please don't misinterpret this post as an attempt to pull .NET down in favor of Java.
BTW, I won't be using my port of dk.brics.automaton in production because it's under the GPL curse and it seems to miss some patterns that it should have found. If you want to give it a try, here it is. You must have J# to build it. The project is misnamed because I thought I originally started porting JRexx. Oh, well.