## Regular Expression Performance Comparison

The following tables provide comparisons between the following regular expression libraries:

GRETA.

The Boost regex library.

Henry Spencer's regular expression library - this is provided for comparison as a typical non-backtracking implementation.

Philip Hazel's PCRE library.

### Details

Machine: Intel Pentium 4 2.8GHz PC.

Compiler: %compiler%.

C++ Standard Library: %library%.

OS: %os%.

Boost version: %boost%.

PCRE version: %pcre%.

As ever care should be taken in interpreting the results, only sensible regular expressions (rather than pathological cases) are given, most are taken from the Boost regex examples, or from the Library of Regular Expressions. In addition, some variation in the relative performance of these libraries can be expected on other machines - as memory access and processor caching effects can be quite large for most finite state machine algorithms.

### Averages

The following are the average relative scores for all the tests: the perfect regular expression library would score 1, in practice anything less than 2 is pretty good.

%averages%

### Comparison 1: Long Search

For each of the following regular expressions the time taken to find all occurrences of the expression within a long English language text was measured (mtent12.txt from Project Gutenberg, 19Mb).

%long_twain_search%

### Comparison 2: Medium Sized Search

For each of the following regular expressions the time taken to find all occurrences of the expression within a medium sized English language text was measured (the first 50K from mtent12.txt).

%short_twain_search%

### Comparison 3: C++ Code Search

For each of the following regular expressions the time taken to find all occurrences of the expression within the C++ source file boost/crc.hpp was measured.

%code_search%

###

### Comparison 4: HTML Document Search

For each of the following regular expressions the time taken to find all occurrences of the expression within the html file libs/libraries.htm was measured.

%html_search%

### Comparison 3: Simple Matches

For each of the following regular expressions the time taken to match against the text indicated was measured.

%short_matches%

© Copyright John Maddock 2003

Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)