Views
- State: published
Regex Engines Benchmarked
|
|
I found a benchmark for Java based regex engines. I ran the benchmark with the latest released versions using JDK 1.4.1, here are my results:
- java.util.regex.Pattern took 813ms
- jregex.Pattern took 781ms
- org.apache.oro.text.regex.Perl5Matcher took 1141ms
- dk.brics.automaton.RegExp took 359ms
- com.karneim.util.collection.regex.Pattern took 375ms
- com.karneim.util.collection.regex.PatternPro took 625ms
In summary, the standard JDK class performs better than older open source regex engines like ORO. JRegex is a better performer, considering that it has more functionality, it may be viable alternative. However, if you need more speed, a fast DFA based engine even though they are less expressive is almost twice as fast.
Out of further curiosity, I tested the C# regex class using a more streamlined benchmark:
- C# regex took 2.53153991699219 secs
- com.karneim.util.collection.regex.Pattern took 0.125 secs
As expected, C#'s immature library rears its ugly head again! C# regex is 20 times slower than JRexx. The next question then is, how does this compare to Perl or Grep?
Last modified 2003-12-22 10:05 AM
I second that.
I would love to see the Perl and grep numbers.
Replies to this comment
I can't duplicate your .NET results..
http://www.codinghorror.com/blog/archives/000065.html
Did you ask the .Net Regex library to compile the regex first?
Did you ask the .Net Regex library to compile the regex first? Or did you leave it in interpreted mode?
Cheers!



Just out of curiosity, do you have any future plans to benchmark perl and grep?