Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

xpressive vs. Boost.Regex with Visual C++

Below are the results of a performance comparison between:

Test Specifications

Hardware:

hyper-threaded 3GHz Xeon with 1Gb RAM

Operating System:

Windows XP Pro

Compiler:

Visual C++ .NET 2003 (7.1)

C++ Standard Library:

Dinkumware, version 313

Boost.Regex Version:

1.33+, BOOST_REGEX_USE_CPP_LOCALE, BOOST_REGEX_RECURSIVE

xpressive Version:

0.9.6a

Comparison 1: Short Matches

The following tests evaluate the time taken to match the expression to the input string. For each result, the top number has been normalized relative to the fastest time, so 1.0 is as good as it gets. The bottom number (in parentheses) is the actual time in seconds. The best time has been marked in green.

Short Matches
static xpressive dynamic xpressive Boost Text Expression
1

(3.2e‑007s)
1.37

(4.4e‑007s)
2.38

(7.6e‑007s)
100- this is a line of ftp response which contains a message string ^([0-9]+)(\-| |$)(.*)$
1

(6.4e‑007s)
1.12

(7.15e‑007s)
1.72

(1.1e‑006s)
1234-5678-1234-456 ([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}
1

(9.82e‑007s)
1.3

(1.28e‑006s)
1.61

(1.58e‑006s)
john_maddock@compuserve.com ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
1

(8.94e‑007s)
1.3

(1.16e‑006s)
1.7

(1.52e‑006s)
foo12@foo.edu ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
1

(9.09e‑007s)
1.28

(1.16e‑006s)
1.67

(1.52e‑006s)
bob.smith@foo.tv ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
1

(3.06e‑007s)
1.07

(3.28e‑007s)
1.95

(5.96e‑007s)
EH10 2QQ ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
1

(3.13e‑007s)
1.09

(3.42e‑007s)
1.86

(5.81e‑007s)
G1 1AA ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
1

(3.2e‑007s)
1.09

(3.5e‑007s)
1.86

(5.96e‑007s)
SW1 1ZZ ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
1

(2.68e‑007s)
1.22

(3.28e‑007s)
2

(5.36e‑007s)
4/1/2001 ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
1

(2.76e‑007s)
1.16

(3.2e‑007s)
1.94

(5.36e‑007s)
12/12/2001 ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
1

(2.98e‑007s)
1.03

(3.06e‑007s)
1.85

(5.51e‑007s)
123 ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
1

(3.2e‑007s)
1.12

(3.58e‑007s)
1.81

(5.81e‑007s)
+3.14159 ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
1

(3.28e‑007s)
1.11

(3.65e‑007s)
1.77

(5.81e‑007s)
-3.14159 ^[-+]?[[:digit:]]*\.?[[:digit:]]*$

Comparison 2: Long Searches

The next test measures the time to find all matches in a long English text. The text is the complete works of Mark Twain, from Project Gutenberg. The text is 19Mb long. As above, the top number is the normalized time and the bottom number is the actual time. The best time is in green.

Long Searches
static xpressive dynamic xpressive Boost Expression
1

(0.019s)
1

(0.019s)
2.98

(0.0566s)
Twain
1

(0.0176s)
1

(0.0176s)
3.17

(0.0556s)
Huck[[:alpha:]]+
3.62

(1.78s)
3.97

(1.95s)
1

(0.492s)
[[:alpha:]]+ing
2.32

(0.344s)
3.06

(0.453s)
1

(0.148s)
^[^ ]*?Twain
1

(0.0576s)
1.05

(0.0606s)
1.15

(0.0664s)
Tom|Sawyer|Huckleberry|Finn
1.24

(0.164s)
1.44

(0.191s)
1

(0.133s)
(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)

PrevUpHomeNext