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?

