Java Regular expression library benchmarks

In the search for the best regular expression (or regex) parser available for Java, I had to satisfy myself by doing some benchmarks. The following table shows the typical results for the following three regular expression matches.

"^(([^:]+)://)?([^:/]+)(:([0-9]+))?(/.*)" , "usd [+-]?[0-9]+.[0-9][0-9]" and "\\b(\\w+)(\\s+\\1)+\\b".

Regular expression libraryTime taken for 10,000 iterationsParses perl5 regex correctly?
org.apache.regexp.* 1.26059mstrue
com.stevesoft.pat.Regex 1.5.36479mstrue
com.ibm.regex.RegularExpression 1.0.22494mstrue
gnu.regexp.RE version 1.1.436032mstrue
kmy.regex.util.Regex 0.1.25157mstrue
java.util.regex.Pattern 1.41122mstrue
jregex.Pattern 1.2_011432mstrue
org.apache.oro.text.regex.Perl5Matcher 2.0.62263mstrue
RegularExpression.RE 1.03946msfalse - fails on URL test
gnu.rex.Rex ??????msunknown
dk.brics.automaton.RegExp1.2511msfalse - fails on URL test
com.karneim.util.collection.regex.Pattern1.1.1543msfalse - fails on URL test
A more detailed breakdown for the above benchmarks!

Bryan Davis has contributed a method to further breakdown the benchmark details. Feel free to take the current java source for the regtest.java for this update.

This test was run on a PIII-650, with 288meg of RAM using j2sdk1.4.0_01. Please run the test on your own machine, and I will post the details here once I work out a good way of analysing the data (if you know of an easy way to create an easier output format for the tests, please feel free to make the changes, and email the changes to me). The source code requires the jars from all the above regular expression libarys which can be found by click the links in the above table. A simple compile.bat will compile and run the tests for you, given you have all the jars in the current working directory.

If you know of any other java regular expression libraries, please do let me know aswell :)


This webpage is Copyright (c) 2002, Damien Mascord tusker@tusker.org