diff --git a/doc/captures.qbk b/doc/captures.qbk index 08abbf9d..eb8ec8c9 100644 --- a/doc/captures.qbk +++ b/doc/captures.qbk @@ -142,7 +142,7 @@ example program shows how this information may be used: Which produces the following output: [pre -Expression: "(([[:lower:\]\]+)|([[:upper:\]\]+))+" +Expression: "((\[\[:lower:\]\]+)|(\[\[:upper:\]\]+))+" Text: "aBBcccDDDDDeeeeeeee" '''**''' Match found '''**''' Sub-Expressions: diff --git a/doc/concepts.qbk b/doc/concepts.qbk index d3f6d837..36ab3d89 100644 --- a/doc/concepts.qbk +++ b/doc/concepts.qbk @@ -58,16 +58,40 @@ an object of type `X::locale_type`. [[X::size_type][][An unsigned integer type, capable of holding the length of a null-terminated string of charT's.]] [[X::string_type][std::basic_string or std::vector][]] [[X::locale_type][Implementation defined][A copy constructible type that represents the locale used by the traits class.]] -[[X::char_class_type][Implementation defined][A bitmask type representing a particular character classification. Multiple values of this type can be bitwise-or'ed together to obtain a new valid value.]] +[[X::char_class_type] + [Implementation defined] + [A bitmask type representing a particular character classification. Multiple values of this type can be bitwise-or'ed together to obtain a new valid value.]] [[X::length(p)][X::size_type][Yields the smallest i such that p\[i\] == 0. Complexity is linear in i.]] -[[v.translate(c)][X::char_type][Returns a character such that for any character d that is to be considered equivalent to c then v.translate(c) == v.translate(d).]] -[[v.translate_nocase(c)][X::char_type][For all characters C that are to be considered equivalent to c when comparisons are to be performed without regard to case, then v.translate_nocase(c) == v.translate_nocase(C).]] -[[v.transform(F1, F2)][X::string_type][Returns a sort key for the character sequence designated by the iterator range \[F1, F2) such that if the character sequence \[G1, G2) sorts before the character sequence [H1, H2) then v.transform(G1, G2) < v.transform(H1, H2). ]] -[[v.transform_primary(F1, F2)][X::string_type][Returns a sort key for the character sequence designated by the iterator range \[F1, F2) such that if the character sequence [G1, G2) sorts before the character sequence \[H1, H2) when character case is not considered then v.transform_primary(G1, G2) < v.transform_primary(H1, H2).]] -[[v.lookup_classname(F1, F2)][X::char_class_type][Converts the character sequence designated by the iterator range \[F1,F2) into a bitmask type that can subsequently be passed to isctype. Values returned from lookup_classname can be safely bitwise or'ed together. Returns 0 if the character sequence is not the name of a character class recognized by X. The value returned shall be independent of the case of the characters in the sequence.]] -[[v.lookup_collatename(F1, F2)][X::string_type][Returns a sequence of characters that represents the collating element consisting of the character sequence designated by the iterator range \[F1, F2). Returns an empty string if the character sequence is not a valid collating element.]] +[[v.translate(c)] + [X::char_type] + [Returns a character such that for any character d that is to be considered equivalent to c then v.translate(c) == v.translate(d).]] +[[v.translate_nocase(c)] + [X::char_type] + [For all characters C that are to be considered equivalent to c when comparisons are to be performed without regard to case, then v.translate_nocase(c) == v.translate_nocase(C).]] +[[v.transform(F1, F2)] + [X::string_type] + [Returns a sort key for the character sequence designated by the iterator range \[F1, F2) such that if + the character sequence \[G1, G2) sorts before the character sequence \[H1, H2) then + v.transform(G1, G2) < v.transform(H1, H2). ]] +[[v.transform_primary(F1, F2)] + [X::string_type] + [Returns a sort key for the character sequence designated by the iterator range \[F1, F2) such that if the + character sequence \[G1, G2) sorts before the character sequence \[H1, H2) when character case is not considered + then v.transform_primary(G1, G2) < v.transform_primary(H1, H2).]] +[[v.lookup_classname(F1, F2)] + [X::char_class_type] + [Converts the character sequence designated by the iterator range \[F1,F2) into a bitmask type that can subsequently + be passed to isctype. Values returned from lookup_classname can be safely bitwise or'ed together. Returns 0 if the + character sequence is not the name of a character class recognized by X. The value returned shall be independent + of the case of the characters in the sequence.]] +[[v.lookup_collatename(F1, F2)] + [X::string_type] + [Returns a sequence of characters that represents the collating element consisting of the character sequence designated + by the iterator range \[F1, F2). Returns an empty string if the character sequence is not a valid collating element.]] [[v.isctype(c, v.lookup_classname (F1, F2))][bool][Returns true if character c is a member of the character class designated by the iterator range \[F1, F2), false otherwise.]] -[[v.value(c, I)][int][Returns the value represented by the digit c in base I if the character c is a valid digit in base I; otherwise returns -1. \[Note: the value of I will only be 8, 10, or 16. -end note\]]] +[[v.value(c, I)] + [int] + [Returns the value represented by the digit c in base I if the character c is a valid digit in base I; otherwise returns -1. \[Note: the value of I will only be 8, 10, or 16. -end note\]]] [[u.imbue(loc)][X::locale_type][Imbues u with the locale loc, returns the previous locale used by u if any. ]] [[v.getloc()][X::locale_type][Returns the current locale used by v if any. ]] ] diff --git a/doc/gcc-performance.html b/doc/gcc-performance.html deleted file mode 100644 index 5dcea95a..00000000 --- a/doc/gcc-performance.html +++ /dev/null @@ -1,543 +0,0 @@ - - - - Regular Expression Performance Comparison (gcc 3.2) - - - - - - - -

Regular Expression Performance Comparison

-

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

-

The Boost regex library.

-

The GNU regular expression library.

-

Philip Hazel's PCRE library.

-

Details

-

Machine: Intel Pentium 4 2.8GHz PC.

-

Compiler: GNU C++ version 3.2 20020927 (prerelease).

-

C++ Standard Library: GNU libstdc++ version 20020927.

-

OS: Cygwin.

-

Boost version: 1.31.0.

-

PCRE version: 4.1.

-

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. In each case the first figure given is the relative time - taken (so a value of 1.0 is as good as it gets), while the second figure is the - actual time taken.

-

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.

- - - - - - - - - - - - - -
BoostBoost + C++ localePOSIXPCRE
1.45031.49124108.3721.56255
-
-
-

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). 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionBoostBoost + C++ localePOSIXPCRE
Twain3.49
- (0.205s)
4.09
- (0.24s)
65.2
- (3.83s)
1
- (0.0588s)
Huck[[:alpha:]]+3.86
- (0.203s)
4.52
- (0.238s)
100
- (5.26s)
1
- (0.0526s)
[[:alpha:]]+ing1.01
- (1.23s)
1
- (1.22s)
4.95
- (6.04s)
4.67
- (5.71s)
^[^ ]*?Twain1
- (0.31s)
1.05
- (0.326s)
NA3.32
- (1.03s)
Tom|Sawyer|Huckleberry|Finn1.02
- (0.125s)
1
- (0.123s)
165
- (20.3s)
1.08
- (0.133s)
(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)1
- (0.345s)
1.03
- (0.355s)
NA1.71
- (0.59s)
-
-
-

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). 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionBoostBoost + C++ localePOSIXPCRE
Twain1.8
- (0.000519s)
2.14
- (0.000616s)
9.08
- (0.00262s)
1
- (0.000289s)
Huck[[:alpha:]]+3.65
- (0.000499s)
4.36
- (0.000597s)
1
- (0.000137s)
1.43
- (0.000196s)
[[:alpha:]]+ing1
- (0.00258s)
1
- (0.00258s)
5.28
- (0.0136s)
5.63
- (0.0145s)
^[^ ]*?Twain1
- (0.000929s)
1.03
- (0.000957s)
NA2.82
- (0.00262s)
Tom|Sawyer|Huckleberry|Finn1
- (0.000812s)
1
- (0.000812s)
60.1
- (0.0488s)
1.28
- (0.00104s)
(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)1.02
- (0.00178s)
1
- (0.00174s)
242
- (0.421s)
1.3
- (0.00227s)
-
-
-

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. 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionBoostBoost + C++ localePOSIXPCRE
^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\<\w+\>([ - ]*\([^)]*\))?[[:space:]]*)*(\<\w*\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\{|:[^;\{()]*\{)1.04
- (0.000144s)
1
- (0.000139s)
862
- (0.12s)
4.56
- (0.000636s)
(^[ - ]*#(?:[^\\\n]|\\[^\n_[:punct:][:alnum:]]*[\n[:punct:][:word:]])*)|(//[^\n]*|/\*.*?\*/)|\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\>|('(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")|\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\>1
- (0.0139s)
1.01
- (0.0141s)
NA1.55
- (0.0216s)
^[ ]*#[ ]*include[ ]+("[^"]+"|<[^>]+>)1.04
- (0.000332s)
1
- (0.000318s)
130
- (0.0413s)
1.72
- (0.000547s)
^[ ]*#[ ]*include[ ]+("boost/[^"]+"|<boost/[^>]+>)1.02
- (0.000323s)
1
- (0.000318s)
150
- (0.0476s)
1.72
- (0.000547s)
-
-

-

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. 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionBoostBoost + C++ localePOSIXPCRE
beman|john|dave1.03
- (0.000367s)
1
- (0.000357s)
47.4
- (0.0169s)
1.16
- (0.000416s)
<p>.*?</p>1.25
- (0.000459s)
1
- (0.000367s)
NA1.03
- (0.000376s)
<a[^>]+href=("[^"]*"|[^[:space:]]+)[^>]*>1
- (0.000509s)
1.02
- (0.000518s)
305
- (0.155s)
1.1
- (0.000558s)
<h[12345678][^>]*>.*?</h[12345678]>1.04
- (0.00025s)
1
- (0.00024s)
NA1.16
- (0.000279s)
<img[^>]+src=("[^"]*"|[^[:space:]]+)[^>]*>2.22
- (0.000489s)
1.69
- (0.000372s)
148
- (0.0326s)
1
- (0.00022s)
<font[^>]+face=("[^"]*"|[^[:space:]]+)[^>]*>.*?</font>1.71
- (0.000371s)
1.75
- (0.000381s)
NA1
- (0.000218s)
-
-
-

Comparison 3: Simple Matches

-

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ExpressionTextBoostBoost + C++ localePOSIXPCRE
abcabc1.36
- (2.15e-07s)
1.36
- (2.15e-07s)
2.76
- (4.34e-07s)
1
- (1.58e-07s)
^([0-9]+)(\-| |$)(.*)$100- this is a line of ftp response which contains a message string1.55
- (7.26e-07s)
1.51
- (7.07e-07s)
319
- (0.000149s)
1
- (4.67e-07s)
([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}1234-5678-1234-4561.96
- (9.54e-07s)
1.96
- (9.54e-07s)
44.5
- (2.17e-05s)
1
- (4.87e-07s)
^([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})(\]?)$john@johnmaddock.co.uk1.22
- (1.51e-06s)
1.23
- (1.53e-06s)
162
- (0.000201s)
1
- (1.24e-06s)
^([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})(\]?)$foo12@foo.edu1.28
- (1.47e-06s)
1.3
- (1.49e-06s)
104
- (0.00012s)
1
- (1.15e-06s)
^([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})(\]?)$bob.smith@foo.tv1.28
- (1.47e-06s)
1.3
- (1.49e-06s)
113
- (0.00013s)
1
- (1.15e-06s)
^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$EH10 2QQ1.38
- (4.68e-07s)
1.41
- (4.77e-07s)
13.5
- (4.59e-06s)
1
- (3.39e-07s)
^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$G1 1AA1.28
- (4.35e-07s)
1.25
- (4.25e-07s)
11.7
- (3.97e-06s)
1
- (3.39e-07s)
^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$SW1 1ZZ1.32
- (4.53e-07s)
1.31
- (4.49e-07s)
12.2
- (4.2e-06s)
1
- (3.44e-07s)
^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$4/1/20011.16
- (3.82e-07s)
1.2
- (3.96e-07s)
13.9
- (4.59e-06s)
1
- (3.29e-07s)
^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$12/12/20011.38
- (4.49e-07s)
1.38
- (4.49e-07s)
16
- (5.2e-06s)
1
- (3.25e-07s)
^[-+]?[[:digit:]]*\.?[[:digit:]]*$1231.19
- (7.64e-07s)
1.16
- (7.45e-07s)
7.51
- (4.81e-06s)
1
- (6.4e-07s)
^[-+]?[[:digit:]]*\.?[[:digit:]]*$+3.141591.32
- (8.97e-07s)
1.31
- (8.88e-07s)
14
- (9.48e-06s)
1
- (6.78e-07s)
^[-+]?[[:digit:]]*\.?[[:digit:]]*$-3.141591.32
- (8.97e-07s)
1.31
- (8.88e-07s)
14
- (9.48e-06s)
1
- (6.78e-07s)
-
-
-
-

© 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)

- - - diff --git a/doc/html/boost_regex/background_information.html b/doc/html/boost_regex/background_information.html index 340d5438..4e2e7b87 100644 --- a/doc/html/boost_regex/background_information.html +++ b/doc/html/boost_regex/background_information.html @@ -37,6 +37,20 @@ and Further Information
FAQ
Performance
+
+
Testing + Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version + 14.0)
+
Testing + leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual + C++ version 14.0)
+
Testing + simple Perl matches (platform = Windows x64, compiler = Microsoft Visual + C++ version 14.0)
+
Testing + simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft + Visual C++ version 14.0)
+
Standards Conformance
Redistributables
diff --git a/doc/html/boost_regex/background_information/history.html b/doc/html/boost_regex/background_information/history.html index 4207a825..8434f678 100644 --- a/doc/html/boost_regex/background_information/history.html +++ b/doc/html/boost_regex/background_information/history.html @@ -59,7 +59,7 @@
- Boost.Regex-5.0.1 + Boost.Regex-5.0.1 (Boost-1.58.0)
    @@ -92,7 +92,7 @@
- Boost.Regex-5.0.0 + Boost.Regex-5.0.0 (Boost-1.56.0)
    diff --git a/doc/html/boost_regex/background_information/locale.html b/doc/html/boost_regex/background_information/locale.html index 3d557b0b..eaca9bfa 100644 --- a/doc/html/boost_regex/background_information/locale.html +++ b/doc/html/boost_regex/background_information/locale.html @@ -59,7 +59,7 @@

    - Win32 + Win32 localization model.

    @@ -91,7 +91,7 @@

    - C + C localization model.

    @@ -115,7 +115,7 @@

    - C++ + C++ localization model.

    @@ -1268,12 +1268,14 @@

    - "Unmatched [ or " + "Unmatched [ or [^"

    + +

    - [208 + 208

    diff --git a/doc/html/boost_regex/background_information/performance.html b/doc/html/boost_regex/background_information/performance.html index 283e1902..fa68de7a 100644 --- a/doc/html/boost_regex/background_information/performance.html +++ b/doc/html/boost_regex/background_information/performance.html @@ -7,7 +7,7 @@ - + @@ -20,12 +20,26 @@

    -PrevUpHomeNext +PrevUpHomeNext
    @@ -54,7 +58,7 @@

    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/boost_regex/background_information/performance/section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html b/doc/html/boost_regex/background_information/performance/section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html new file mode 100644 index 00000000..a4cb0b07 --- /dev/null +++ b/doc/html/boost_regex/background_information/performance/section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html @@ -0,0 +1,523 @@ + + + +Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    +

    Table 8. Testing Perl searches (platform = Windows x64, compiler = Microsoft + Visual C++ version 14.0)

    +
    ++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Expression
    Text +

    +
    +

    + boost 1.60 +

    +
    +

    + PCRE-10.10 +

    +
    +

    + RE2 +

    +
    +

    + std::regex +

    +
    +

    + boost::xpressive::cregex +

    +
    +

    + (?i)<a[^>]+href=("[^"]*"|[^[:space:]]+)[^>]*>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 1.26
    (320274ns)
    +

    +
    +

    + 1.00
    (253424ns)
    +

    +
    +

    + 1.45
    (366324ns)
    +

    +
    +

    + - +

    +
    +

    + 3.00
    (759495ns)
    +

    +
    +

    + (?i)<font[^>]+face=("[^"]*"|[^[:space:]]+)[^>]*>.*?</font>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 2.94
    (198426ns)
    +

    +
    +

    + 1.28
    (86670ns)
    +

    +
    +

    + 1.00
    (67463ns)
    +

    +
    +

    + - +

    +
    +

    + 2.92
    (197323ns)
    +

    +
    +

    + (?i)<h[12345678][^>]*>.*?</h[12345678]>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 2.42
    (196304ns)
    +

    +
    +

    + 1.26
    (102129ns)
    +

    +
    +

    + 1.00
    (81160ns)
    +

    +
    +

    + - +

    +
    +

    + 5.12
    (415932ns)
    +

    +
    +

    + (?i)<img[^>]+src=("[^"]*"|[^[:space:]]+)[^>]*>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 2.87
    (196348ns)
    +

    +
    +

    + 1.28
    (87365ns)
    +

    +
    +

    + 1.00
    (68502ns)
    +

    +
    +

    + - +

    +
    +

    + 3.25
    (222612ns)
    +

    +
    +

    + (?i)<p>.*?</p>
    In file: + ....../libs/libraries.htm +

    +
    +

    + 2.78
    (194346ns)
    +

    +
    +

    + 1.27
    (88709ns)
    +

    +
    +

    + 1.00
    (70020ns)
    +

    +
    +

    + - +

    +
    +

    + 4.03
    (282425ns)
    +

    +
    +

    + (\w+)\s*(\([^()]++(?:(?2)[^()]++)*+[^)]*\))\s*(\{[^{}]++((?3)[^{}]++)*+[^}]*+\})
    + In file: boost/multiprecision/number.hpp +

    +
    +

    + 1.00
    (1094575ns)
    +

    +
    +

    + 2.87
    (3136734ns)
    +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + (^[ \t]*#(?:(?>[^\\\n]+)|\\(?>\s*\n|.))*)|
    + In file: boost/multiprecision/number.hpp +

    +
    +

    + 1.92
    (11651545ns)
    +

    +
    +

    + 1.00
    (6057879ns)
    +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + 1.55
    (9388319ns)
    +

    +
    +

    + (template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\w+([ + ]*\([^)]*\))?[\u0 ...
    In file: boost/multiprecision/number.hpp +

    +
    +

    + 29.23
    (8736875ns)
    +

    +
    +

    + 38.71
    (11569512ns)
    +

    +
    +

    + 1.00
    (298862ns)
    +

    +
    +

    + 995.92
    (297642713ns)
    +

    +
    +

    + 27.63
    (8258368ns)
    +

    +
    +

    + Beman|John|Dave
    In file: ....../libs/libraries.htm +

    +
    +

    + 1.60
    (153603ns)
    +

    +
    +

    + 1.10
    (105220ns)
    +

    +
    +

    + 2.55
    (244839ns)
    +

    +
    +

    + 8.53
    (819095ns)
    +

    +
    +

    + 1.00
    (96081ns)
    +

    +
    +

    + \w+\s*(\([^()]++(?:(?1)[^()]++)*+[^)]*\))
    + In file: boost/multiprecision/number.hpp +

    +
    +

    + 1.00
    (1099128ns)
    +

    +
    +

    + 1.66
    (1824126ns)
    +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + \{[^{}]++((?0)[^{}]++)*+[^}]*+\}
    In + file: boost/multiprecision/number.hpp +

    +
    +

    + 1.60
    (243611ns)
    +

    +
    +

    + 1.00
    (152166ns)
    +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + - +

    +
    +

    + ^[ ]*#[ ]*include[ ]+("[^"]+"|<[^>]+>)
    + In file: boost/multiprecision/number.hpp +

    +
    +

    + 1.54
    (260929ns)
    +

    +
    +

    + 1.18
    (198707ns)
    +

    +
    +

    + 1.81
    (305923ns)
    +

    +
    +

    + 8.53
    (1440180ns)
    +

    +
    +

    + 1.00
    (168902ns)
    +

    +
    +

    + ^[ ]*#[ ]*include[ ]+("boost/[^"]+"|<boost/[^>]+>)
    + In file: boost/multiprecision/number.hpp +

    +
    +

    + 1.52
    (256685ns)
    +

    +
    +

    + 1.17
    (198358ns)
    +

    +
    +

    + 1.80
    (303602ns)
    +

    +
    +

    + 8.51
    (1438197ns)
    +

    +
    +

    + 1.00
    (168968ns)
    +

    +
    +
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/boost_regex/background_information/performance/section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html b/doc/html/boost_regex/background_information/performance/section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html new file mode 100644 index 00000000..03c6ee55 --- /dev/null +++ b/doc/html/boost_regex/background_information/performance/section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html @@ -0,0 +1,130 @@ + + + +Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    +

    Table 9. Testing leftmost-longest searches (platform = Windows x64, compiler + = Microsoft Visual C++ version 14.0)

    +
    +++++ + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Expression
    Text +

    +
    +

    + boost 1.60 +

    +
    +

    + std::regex +

    +
    +

    + <a[^>]+href=("[^"]*"|[^[:space:]]+)[^>]*>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 1.00
    (1518659ns)
    +

    +
    +

    + 7.17
    (10890189ns)
    +

    +
    +

    + <img[^>]+src=("[^"]*"|[^[:space:]]+)[^>]*>
    + In file: ....../libs/libraries.htm +

    +
    +

    + 1.00
    (185869ns)
    +

    +
    +

    + 3.77
    (700484ns)
    +

    +
    +

    + Beman|John|Dave
    In file: ....../libs/libraries.htm +

    +
    +

    + 1.00
    (165840ns)
    +

    +
    +

    + 4.95
    (820933ns)
    +

    +
    +
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/boost_regex/background_information/performance/section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html b/doc/html/boost_regex/background_information/performance/section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html new file mode 100644 index 00000000..045b2829 --- /dev/null +++ b/doc/html/boost_regex/background_information/performance/section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html @@ -0,0 +1,556 @@ + + + +Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    +

    Table 10. Testing simple Perl matches (platform = Windows x64, compiler = + Microsoft Visual C++ version 14.0)

    +
    ++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Expression
    Text +

    +
    +

    + boost 1.60 +

    +
    +

    + PCRE-10.10 +

    +
    +

    + RE2 +

    +
    +

    + std::regex +

    +
    +

    + boost::xpressive::cregex +

    +
    +

    + ([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}
    + 1234-5678-1234-456 +

    +
    +

    + 2.03
    (323ns)
    +

    +
    +

    + 1.25
    (198ns)
    +

    +
    +

    + 1.00
    (159ns)
    +

    +
    +

    + 20.73
    (3296ns)
    +

    +
    +

    + 1.38
    (220ns)
    +

    +
    +

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

    +
    +

    + 1.71
    (257ns)
    +

    +
    +

    + 2.01
    (302ns)
    +

    +
    +

    + 2.38
    (357ns)
    +

    +
    +

    + 30.81
    (4622ns)
    +

    +
    +

    + 1.00
    (150ns)
    +

    +
    +

    + ^([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})(\ + ...
    bob.smith@foo.tv +

    +
    +

    + 2.66
    (404ns)
    +

    +
    +

    + 2.09
    (317ns)
    +

    +
    +

    + 1.00
    (152ns)
    +

    +
    +

    + 38.14
    (5798ns)
    +

    +
    +

    + 1.87
    (284ns)
    +

    +
    +

    + ^([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})(\ + ...
    foo12@foo.edu +

    +
    +

    + 2.90
    (406ns)
    +

    +
    +

    + 2.31
    (323ns)
    +

    +
    +

    + 1.00
    (140ns)
    +

    +
    +

    + 41.41
    (5797ns)
    +

    +
    +

    + 2.00
    (280ns)
    +

    +
    +

    + ^([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})(\ + ...
    john@johnmaddock.co.uk +

    +
    +

    + 2.74
    (477ns)
    +

    +
    +

    + 2.17
    (378ns)
    +

    +
    +

    + 1.00
    (174ns)
    +

    +
    +

    + 38.15
    (6638ns)
    +

    +
    +

    + 2.20
    (382ns)
    +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + +3.14159 +

    +
    +

    + 1.63
    (171ns)
    +

    +
    +

    + 1.14
    (120ns)
    +

    +
    +

    + 1.13
    (119ns)
    +

    +
    +

    + 34.15
    (3586ns)
    +

    +
    +

    + 1.00
    (105ns)
    +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + -3.14159 +

    +
    +

    + 1.69
    (171ns)
    +

    +
    +

    + 1.18
    (119ns)
    +

    +
    +

    + 1.18
    (119ns)
    +

    +
    +

    + 35.54
    (3590ns)
    +

    +
    +

    + 1.00
    (101ns)
    +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + 123 +

    +
    +

    + 1.60
    (149ns)
    +

    +
    +

    + 1.15
    (107ns)
    +

    +
    +

    + 1.10
    (102ns)
    +

    +
    +

    + 39.99
    (3719ns)
    +

    +
    +

    + 1.00
    (93ns)
    +

    +
    +

    + ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
    + 12/12/2001 +

    +
    +

    + 1.65
    (162ns)
    +

    +
    +

    + 1.00
    (98ns)
    +

    +
    +

    + 1.31
    (128ns)
    +

    +
    +

    + 16.57
    (1624ns)
    +

    +
    +

    + 1.03
    (101ns)
    +

    +
    +

    + ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
    + 4/1/2001 +

    +
    +

    + 1.58
    (153ns)
    +

    +
    +

    + 1.00
    (97ns)
    +

    +
    +

    + 1.19
    (115ns)
    +

    +
    +

    + 16.54
    (1604ns)
    +

    +
    +

    + 1.02
    (99ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + EH10 2QQ +

    +
    +

    + 1.57
    (170ns)
    +

    +
    +

    + 1.00
    (108ns)
    +

    +
    +

    + 1.10
    (119ns)
    +

    +
    +

    + 21.83
    (2358ns)
    +

    +
    +

    + 1.00
    (108ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + G1 1AA +

    +
    +

    + 1.50
    (159ns)
    +

    +
    +

    + 1.01
    (107ns)
    +

    +
    +

    + 1.05
    (111ns)
    +

    +
    +

    + 17.67
    (1873ns)
    +

    +
    +

    + 1.00
    (106ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + SW1 1ZZ +

    +
    +

    + 1.53
    (164ns)
    +

    +
    +

    + 1.00
    (107ns)
    +

    +
    +

    + 1.07
    (115ns)
    +

    +
    +

    + 18.05
    (1931ns)
    +

    +
    +

    + 1.00
    (107ns)
    +

    +
    +

    + abc
    abc +

    +
    +

    + 2.10
    (128ns)
    +

    +
    +

    + 1.00
    (61ns)
    +

    +
    +

    + 1.30
    (79ns)
    +

    +
    +

    + 9.89
    (603ns)
    +

    +
    +

    + 1.25
    (76ns)
    +

    +
    +
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/boost_regex/background_information/performance/section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html b/doc/html/boost_regex/background_information/performance/section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html new file mode 100644 index 00000000..6ba1b4c7 --- /dev/null +++ b/doc/html/boost_regex/background_information/performance/section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_.html @@ -0,0 +1,328 @@ + + + +Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) + + + + + + + + + + + + + + + +
    Boost C++ LibrariesHomeLibrariesPeopleFAQMore
    +
    +
    +PrevUpHomeNext +
    +
    + +
    +

    Table 11. Testing simple leftmost-longest matches (platform = Windows x64, + compiler = Microsoft Visual C++ version 14.0)

    +
    +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    + Expression
    Text +

    +
    +

    + boost 1.60 +

    +
    +

    + std::regex +

    +
    +

    + ([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}
    + 1234-5678-1234-456 +

    +
    +

    + 1.00
    (490ns)
    +

    +
    +

    + 6.88
    (3372ns)
    +

    +
    +

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

    +
    +

    + 1.00
    (554ns)
    +

    +
    +

    + - +

    +
    +

    + ^([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})(\ + ...
    bob.smith@foo.tv +

    +
    +

    + 1.00
    (614ns)
    +

    +
    +

    + - +

    +
    +

    + ^([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})(\ + ...
    foo12@foo.edu +

    +
    +

    + 1.00
    (596ns)
    +

    +
    +

    + - +

    +
    +

    + ^([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})(\ + ...
    john@johnmaddock.co.uk +

    +
    +

    + 1.00
    (748ns)
    +

    +
    +

    + - +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + +3.14159 +

    +
    +

    + 1.00
    (372ns)
    +

    +
    +

    + 9.77
    (3635ns)
    +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + -3.14159 +

    +
    +

    + 1.00
    (367ns)
    +

    +
    +

    + 9.84
    (3613ns)
    +

    +
    +

    + ^[-+]?[[:digit:]]*\.?[[:digit:]]*$
    + 123 +

    +
    +

    + 1.00
    (444ns)
    +

    +
    +

    + 8.45
    (3754ns)
    +

    +
    +

    + ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
    + 12/12/2001 +

    +
    +

    + 1.00
    (325ns)
    +

    +
    +

    + 5.19
    (1687ns)
    +

    +
    +

    + ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$
    + 4/1/2001 +

    +
    +

    + 1.00
    (308ns)
    +

    +
    +

    + 5.39
    (1660ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + EH10 2QQ +

    +
    +

    + 1.00
    (356ns)
    +

    +
    +

    + 6.78
    (2415ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + G1 1AA +

    +
    +

    + 1.00
    (315ns)
    +

    +
    +

    + 6.14
    (1935ns)
    +

    +
    +

    + ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$
    + SW1 1ZZ +

    +
    +

    + 1.00
    (346ns)
    +

    +
    +

    + 5.68
    (1967ns)
    +

    +
    +

    + abc
    abc +

    +
    +

    + 1.00
    (287ns)
    +

    +
    +

    + 2.32
    (667ns)
    +

    +
    +
    +
    +
    + + + +
    +
    +
    +PrevUpHomeNext +
    + + diff --git a/doc/html/boost_regex/background_information/standards.html b/doc/html/boost_regex/background_information/standards.html index 3ed4f8e4..cd722bd0 100644 --- a/doc/html/boost_regex/background_information/standards.html +++ b/doc/html/boost_regex/background_information/standards.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
    -PrevUpHomeNext +PrevUpHomeNext

    @@ -29,7 +29,7 @@

    - C++ + C++

    Boost.Regex is intended to conform to the Technical @@ -37,7 +37,7 @@

    - ECMAScript + ECMAScript / JavaScript

    @@ -568,7 +568,7 @@


    -PrevUpHomeNext +PrevUpHomeNext
    diff --git a/doc/html/boost_regex/install.html b/doc/html/boost_regex/install.html index 6cde5760..7604ade8 100644 --- a/doc/html/boost_regex/install.html +++ b/doc/html/boost_regex/install.html @@ -60,7 +60,7 @@

    - Building + Building With Unicode and ICU Support

    diff --git a/doc/html/boost_regex/ref/basic_regex.html b/doc/html/boost_regex/ref/basic_regex.html index e9e55ffa..1b53aab3 100644 --- a/doc/html/boost_regex/ref/basic_regex.html +++ b/doc/html/boost_regex/ref/basic_regex.html @@ -325,7 +325,7 @@ basic_regex.

    -

    Table 1. basic_regex default construction postconditions

    +

    Table 1. basic_regex default construction postconditions

    @@ -403,7 +403,7 @@ flags specified in f.

    -

    Table 2. Postconditions for basic_regex construction

    +

    Table 2. Postconditions for basic_regex construction

    @@ -506,7 +506,7 @@ specified in f.

    -

    Table 3. Postconditions for basic_regex construction

    +

    Table 3. Postconditions for basic_regex construction

    @@ -608,7 +608,7 @@ according the option flags specified in f.

    -

    Table 4. Postconditions for basic_regex construction

    +

    Table 4. Postconditions for basic_regex construction

    @@ -716,7 +716,7 @@ flags specified in f.

    -

    Table 5. Postconditions for basic_regex construction

    +

    Table 5. Postconditions for basic_regex construction

    @@ -816,7 +816,7 @@ flags specified in f.

    -

    Table 6. Postconditions for basic_regex construction

    +

    Table 6. Postconditions for basic_regex construction

    @@ -1002,7 +1002,7 @@ in f.

    -

    Table 7. Postconditions for basic_regex::assign

    +

    Table 7. Postconditions for basic_regex::assign

    diff --git a/doc/html/boost_regex/ref/concepts/traits_concept.html b/doc/html/boost_regex/ref/concepts/traits_concept.html index bea0c69d..cf7d1430 100644 --- a/doc/html/boost_regex/ref/concepts/traits_concept.html +++ b/doc/html/boost_regex/ref/concepts/traits_concept.html @@ -35,7 +35,7 @@

    - Minimal + Minimal requirements.

    diff --git a/doc/html/boost_regex/ref/internal_details/uni_iter.html b/doc/html/boost_regex/ref/internal_details/uni_iter.html index 427c31a0..855a4aa1 100644 --- a/doc/html/boost_regex/ref/internal_details/uni_iter.html +++ b/doc/html/boost_regex/ref/internal_details/uni_iter.html @@ -31,11 +31,7 @@ Synopsis -

    -

    #include <boost/regex/pending/unicode_iterator.hpp>
    -

    -

    template <class BaseIterator, class U16Type = ::boost::uint16_t>
     class u32_to_u16_iterator;
     
    diff --git a/doc/html/boost_regex/ref/non_std_strings/icu/intro.html b/doc/html/boost_regex/ref/non_std_strings/icu/intro.html
    index a05d2704..9aeaedf9 100644
    --- a/doc/html/boost_regex/ref/non_std_strings/icu/intro.html
    +++ b/doc/html/boost_regex/ref/non_std_strings/icu/intro.html
    @@ -39,7 +39,7 @@
     

    In order to use this header you will need the ICU library, and you will need to have built the Boost.Regex library - with ICU + with ICU support enabled.

    diff --git a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html index ad59a8d0..6b64126d 100644 --- a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html +++ b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html @@ -83,7 +83,7 @@

    - regex_match + regex_match (second overload)
    template <class charT, class T>
    @@ -150,7 +150,7 @@
     
    - regex_search + regex_search (second overload)
    template <class charT, class T>
    diff --git a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html
    index 362773e0..b84f5941 100644
    --- a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html
    +++ b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html
    @@ -69,7 +69,7 @@
     
    - regex_token_iterator + regex_token_iterator creation helpers
    template <class charT>
    diff --git a/doc/html/boost_regex/syntax/basic_extended.html b/doc/html/boost_regex/syntax/basic_extended.html
    index 64889e6c..a4a13cc3 100644
    --- a/doc/html/boost_regex/syntax/basic_extended.html
    +++ b/doc/html/boost_regex/syntax/basic_extended.html
    @@ -55,7 +55,7 @@
     
    .[{}()\*+?|^$
    - Wildcard: + Wildcard:

    The single character '.' when used outside of a character set will match @@ -73,7 +73,7 @@

    - Anchors: + Anchors:

    A '^' character shall match the start of a line when used as the first character @@ -85,7 +85,7 @@

    - Marked + Marked sub-expressions:

    @@ -97,7 +97,7 @@

    - Repeats: + Repeats:

    Any atom (a single character, a marked sub-expression, or a character class) @@ -183,7 +183,7 @@ cab

    - Back + Back references:

    @@ -227,7 +227,7 @@ cab

    - Character + Character sets:

    @@ -240,7 +240,8 @@ cab

    - Single characters: + Single + characters:

    For example [abc], will match any of the characters 'a', 'b', @@ -248,7 +249,7 @@ cab

    - Character + Character ranges:

    @@ -264,7 +265,7 @@ cab

    - Negation: + Negation:

    If the bracket-expression begins with the ^ character, then it matches the @@ -273,7 +274,7 @@ cab

    - Character + Character classes:

    @@ -283,7 +284,7 @@ cab

    - Collating + Collating Elements:

    @@ -311,7 +312,7 @@ cab

    - Equivalence + Equivalence classes:

    @@ -328,7 +329,7 @@ cab

    - Combinations: + Combinations:

    All of the above can be combined in one character set declaration, for example: @@ -362,7 +363,7 @@ cab

    - Escapes + Escapes matching a specific character

    @@ -551,7 +552,7 @@ cab

    - "Single + "Single character" character classes:

    diff --git a/doc/html/boost_regex/syntax/basic_syntax.html b/doc/html/boost_regex/syntax/basic_syntax.html index 0d4ddf3f..a510f1a5 100644 --- a/doc/html/boost_regex/syntax/basic_syntax.html +++ b/doc/html/boost_regex/syntax/basic_syntax.html @@ -54,7 +54,7 @@

    .[\*^$
    - Wildcard: + Wildcard:

    The single character '.' when used outside of a character set will match @@ -72,7 +72,7 @@

- Anchors: + Anchors:

A '^' character shall match the start of a line when used as the first character @@ -84,8 +84,7 @@

- Marked - sub-expressions: + Marked sub-expressions:

A section beginning \( and ending @@ -96,7 +95,7 @@

- Repeats: + Repeats:

Any atom (a single character, a marked sub-expression, or a character class) @@ -154,7 +153,7 @@ aaaa

- Back + Back references:

@@ -173,7 +172,7 @@ aaaa

aaabba
- Character + Character sets:

@@ -186,7 +185,7 @@ aaaa

- Single + Single characters:

@@ -195,7 +194,7 @@ aaaa

- Character + Character ranges:

@@ -211,7 +210,7 @@ aaaa

- Negation: + Negation:

If the bracket-expression begins with the ^ character, then it matches the @@ -220,7 +219,7 @@ aaaa

- Character + Character classes:

@@ -230,7 +229,7 @@ aaaa

- Collating + Collating Elements:

@@ -259,7 +258,7 @@ aaaa

- Equivalence + Equivalence classes:

@@ -276,7 +275,7 @@ aaaa

- Combinations: + Combinations:

All of the above can be combined in one character set declaration, for example: @@ -381,9 +380,9 @@ aaaa -

- *? -

+
  • + ? +

diff --git a/doc/html/boost_regex/syntax/character_classes/std_char_clases.html b/doc/html/boost_regex/syntax/character_classes/std_char_clases.html deleted file mode 100644 index d72a3696..00000000 --- a/doc/html/boost_regex/syntax/character_classes/std_char_clases.html +++ /dev/null @@ -1,396 +0,0 @@ - - - -Character Classes that are Always Supported - - - - - - - - - - - - - - - -
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
-


-
-PrevUpHomeNext -
-
- -

- The following character class names are always supported by Boost.Regex: -

-
----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- Name -

-
-

- POSIX-standard name -

-
-

- Description -

-
-

- alnum -

-
-

- Yes -

-
-

- Any alpha-numeric character. -

-
-

- alpha -

-
-

- Yes -

-
-

- Any alphabetic character. -

-
-

- blank -

-
-

- Yes -

-
-

- Any whitespace character that is not a line separator. -

-
-

- cntrl -

-
-

- Yes -

-
-

- Any control character. -

-
-

- d -

-
-

- No -

-
-

- Any decimal digit -

-
-

- digit -

-
-

- Yes -

-
-

- Any decimal digit. -

-
-

- graph -

-
-

- Yes -

-
-

- Any graphical character. -

-
-

- l -

-
-

- No -

-
-

- Any lower case character. -

-
-

- lower -

-
-

- Yes -

-
-

- Any lower case character. -

-
-

- print -

-
-

- Yes -

-
-

- Any printable character. -

-
-

- punct -

-
-

- Yes -

-
-

- Any punctuation character. -

-
-

- s -

-
-

- No -

-
-

- Any whitespace character. -

-
-

- space -

-
-

- Yes -

-
-

- Any whitespace character. -

-
-

- unicode -

-
-

- No -

-
-

- Any extended character whose code point is above 255 in value. -

-
-

- u -

-
-

- No -

-
-

- Any upper case character. -

-
-

- upper -

-
-

- Yes -

-
-

- Any upper case character. -

-
-

- w -

-
-

- No -

-
-

- Any word character (alphanumeric characters plus the underscore). -

-
-

- word -

-
-

- No -

-
-

- Any word character (alphanumeric characters plus the underscore). -

-
-

- xdigit -

-
-

- Yes -

-
-

- Any hexadecimal digit character. -

-
-
- - - -
-
-
-PrevUpHomeNext -
- - diff --git a/doc/html/boost_regex/syntax/collating_names/posix_symbolic_names.html b/doc/html/boost_regex/syntax/collating_names/posix_symbolic_names.html index 3942248b..21ba2e5d 100644 --- a/doc/html/boost_regex/syntax/collating_names/posix_symbolic_names.html +++ b/doc/html/boost_regex/syntax/collating_names/posix_symbolic_names.html @@ -481,9 +481,7 @@

-

- # -

+
diff --git a/doc/html/boost_regex/syntax/perl_syntax.html b/doc/html/boost_regex/syntax/perl_syntax.html index d806472f..cbde9c41 100644 --- a/doc/html/boost_regex/syntax/perl_syntax.html +++ b/doc/html/boost_regex/syntax/perl_syntax.html @@ -399,9 +399,9 @@ sets

- A character set is a bracket-expression starting with [ - and ending with ], it defines a set of characters, and - matches any single character that is a member of that set. + A character set is a bracket-expression starting with [] and ending + with , it defines a set of characters, and matches + any single character that is a member of that set.

A bracket expression may contain any combination of the following: @@ -702,7 +702,7 @@

- "Single + "Single character" character classes:

@@ -1418,7 +1418,7 @@ [::] [..]

  • - Escaped characters [^] + Escaped characters \
  • Character set (bracket expression) [] diff --git a/doc/html/boost_regex/unicode.html b/doc/html/boost_regex/unicode.html index b10b6352..a74d9c8d 100644 --- a/doc/html/boost_regex/unicode.html +++ b/doc/html/boost_regex/unicode.html @@ -58,12 +58,12 @@
    - Use + Use a Unicode Aware Regular Expression Type.

    If you have the ICU - library, then Boost.Regex can be configured + library, then Boost.Regex can be configured to make use of it, and provide a distinct regular expression type (boost::u32regex), that supports both Unicode specific character properties, and the searching of text that is encoded in either UTF-8, UTF-16, or UTF-32. See: ICU diff --git a/doc/html/index.html b/doc/html/index.html index 70ec17f7..76b7e437 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -184,6 +184,20 @@ and Further Information

    FAQ
    Performance
    +
    +
    Testing + Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version + 14.0)
    +
    Testing + leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual + C++ version 14.0)
    +
    Testing + simple Perl matches (platform = Windows x64, compiler = Microsoft Visual + C++ version 14.0)
    +
    Testing + simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft + Visual C++ version 14.0)
    +
    Standards Conformance
    Redistributables
    @@ -198,7 +212,7 @@

    - +

    Last revised: October 05, 2015 at 18:11:16 GMT

    Last revised: October 15, 2015 at 12:24:00 GMT


    diff --git a/doc/icu_strings.qbk b/doc/icu_strings.qbk index c3e3b873..e38e0431 100644 --- a/doc/icu_strings.qbk +++ b/doc/icu_strings.qbk @@ -20,7 +20,7 @@ expressions in a Unicode aware environment. In order to use this header you will need the [@http://www.ibm.com/software/globalization/icu/ ICU library], and you will need to have built the Boost.Regex library with -[link boost_regex.install.building_with_unicode_and_icu_support ICU support enabled]. +[link boost_regex.install.building_with_unicode_and_icu_su ICU support enabled]. The header will enable you to: diff --git a/doc/locale.qbk b/doc/locale.qbk index 8afee5ff..44d709db 100644 --- a/doc/locale.qbk +++ b/doc/locale.qbk @@ -178,7 +178,7 @@ Custom error messages are loaded as follows: [[204][REG_ECTYPE]["Invalid character class name" ]] [[205][REG_EESCAPE]["Trailing backslash" ]] [[206][REG_ESUBREG]["Invalid back reference" ]] - [[207][REG_EBRACK]["Unmatched [ or [^" ]] + [[207][REG_EBRACK]["Unmatched \[ or \[^" ]] [[208][REG_EPAREN]["Unmatched ( or \\(" ]] [[209][REG_EBRACE]["Unmatched \\{" ]] [[210][REG_BADBR]["Invalid content of \\{\\}" ]] diff --git a/doc/performance.qbk b/doc/performance.qbk index 47d72779..4e4942a6 100644 --- a/doc/performance.qbk +++ b/doc/performance.qbk @@ -14,8 +14,7 @@ thread synchronisation), but not by much. The following pages compare Boost.Regex with various other regular expression libraries for the following compilers: -* [@../vc71-performance.html Visual Studio.Net 2003 (recursive Boost.Regex implementation)]. -* [@../gcc-performance.html Gcc 3.2 (cygwin) (non-recursive Boost.Regex implementation)]. +[performance_all_sections] [endsect] diff --git a/doc/regex.qbk b/doc/regex.qbk index 31deed3e..838fbfb4 100644 --- a/doc/regex.qbk +++ b/doc/regex.qbk @@ -1,6 +1,6 @@ [article Boost.Regex - [quickbook 1.3] + [quickbook 1.7] [copyright 1998-2013 John Maddock] [license Distributed under the Boost Software License, Version 1.0. @@ -12,6 +12,8 @@ [/last-revision $Date$] ] +[import ../performance/doc/performance_tables.qbk] + [template super[x]''''''[x]''''''] [template sub[x]''''''[x]''''''] diff --git a/doc/syntax_perl.qbk b/doc/syntax_perl.qbk index 86156084..17aeb00b 100644 --- a/doc/syntax_perl.qbk +++ b/doc/syntax_perl.qbk @@ -586,7 +586,7 @@ are discarded. The order of precedence for of operators is as follows: # Collation-related bracket symbols `[==] [::] [..]` -# Escaped characters [^\] +# Escaped characters [^\\] # Character set (bracket expression) `[]` # Grouping [^()] # Single-character-ERE duplication [^* + ? {m,n}] diff --git a/doc/unicode.qbk b/doc/unicode.qbk index 5028921f..2e86ad0c 100644 --- a/doc/unicode.qbk +++ b/doc/unicode.qbk @@ -30,7 +30,7 @@ characters, it is not possible to search UTF-8, or even UTF-16 on many platforms If you have the [@http://www.ibm.com/software/globalization/icu/ ICU library], then Boost.Regex can be -[link boost_regex.install.building_with_unicode_and_icu_support +[link boost_regex.install.building_with_unicode_and_icu_su configured to make use of it], and provide a distinct regular expression type (boost::u32regex), that supports both Unicode specific character properties, and the searching diff --git a/doc/vc71-performance.html b/doc/vc71-performance.html deleted file mode 100644 index c847845a..00000000 --- a/doc/vc71-performance.html +++ /dev/null @@ -1,703 +0,0 @@ - - - Regular Expression Performance Comparison - - - - - - -

    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: Microsoft Visual C++ version 7.1.

    -

    C++ Standard Library: Dinkumware standard library version 313.

    -

    OS: Win32.

    -

    Boost version: 1.31.0.

    -

    PCRE version: 3.9.

    -

    - 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 any small number - (say less that 4 or 5) is pretty good.

    -

    - - - - - - - - - - - - - - - - -
    GRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    2.316196.142032.306681.94363124.7522.09365
    -

    -

    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). 

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ExpressionGRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    Twain1
    - (0.0407s)
    1
    - (0.0407s)
    4.18
    - (0.17s)
    4.18
    - (0.17s)
    135
    - (5.48s)
    1.37
    - (0.0557s)
    Huck[[:alpha:]]+1.02
    - (0.0381s)
    1
    - (0.0375s)
    4.53
    - (0.17s)
    4.54
    - (0.17s)
    166
    - (6.23s)
    1.34
    - (0.0501s)
    [[:alpha:]]+ing4.3
    - (4.18s)
    9.93
    - (9.65s)
    1.15
    - (1.12s)
    1
    - (0.972s)
    8.15
    - (7.92s)
    5.85
    - (5.69s)
    ^[^ ]*?Twain6.25
    - (1.84s)
    20.9
    - (6.16s)
    1.56
    - (0.461s)
    1
    - (0.295s)
    NA2.58
    - (0.761s)
    Tom|Sawyer|Huckleberry|Finn6.53
    - (0.711s)
    11.5
    - (1.25s)
    2.3
    - (0.251s)
    1
    - (0.109s)
    196
    - (21.4s)
    1.77
    - (0.193s)
    (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)3.88
    - (0.972s)
    6.48
    - (1.62s)
    1.66
    - (0.416s)
    1
    - (0.251s)
    NA2.48
    - (0.62s)
    -

    -

    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). 

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ExpressionGRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    Twain1
    - (9.05e-005s)
    1.03
    - (9.29e-005s)
    4.92
    - (0.000445s)
    4.92
    - (0.000445s)
    43.2
    - (0.00391s)
    3.18
    - (0.000288s)
    Huck[[:alpha:]]+1
    - (8.56e-005s)
    1
    - (8.56e-005s)
    4.97
    - (0.000425s)
    4.98
    - (0.000426s)
    2.8
    - (0.000239s)
    2.2
    - (0.000188s)
    [[:alpha:]]+ing5.29
    - (0.011s)
    11.8
    - (0.0244s)
    1.19
    - (0.00246s)
    1
    - (0.00207s)
    8.77
    - (0.0182s)
    6.88
    - (0.0142s)
    ^[^ ]*?Twain5.98
    - (0.00462s)
    20.2
    - (0.0156s)
    1.54
    - (0.00119s)
    1
    - (0.000772s)
    NA2.53
    - (0.00195s)
    Tom|Sawyer|Huckleberry|Finn3.42
    - (0.00207s)
    6.31
    - (0.00383s)
    1.71
    - (0.00104s)
    1
    - (0.000606s)
    81.5
    - (0.0494s)
    1.96
    - (0.00119s)
    (Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)1.97
    - (0.00266s)
    3.77
    - (0.00509s)
    1.38
    - (0.00186s)
    1
    - (0.00135s)
    297
    - (0.401s)
    1.77
    - (0.00238s)
    -

    -

    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. 

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ExpressionGRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    ^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\<\w+\>([ - ]*\([^)]*\))?[[:space:]]*)*(\<\w*\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\{|:[^;\{()]*\{)6.67
    - (0.00147s)
    36.9
    - (0.00813s)
    1.03
    - (0.000227s)
    1
    - (0.00022s)
    557
    - (0.123s)
    2.57
    - (0.000566s)
    (^[ - ]*#(?:[^\\\n]|\\[^\n_[:punct:][:alnum:]]*[\n[:punct:][:word:]])*)|(//[^\n]*|/\*.*?\*/)|\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\>|('(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*")|\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\>1
    - (0.00555s)
    3.32
    - (0.0185s)
    2.53
    - (0.0141s)
    1.94
    - (0.0108s)
    NA3.38
    - (0.0188s)
    ^[ ]*#[ ]*include[ ]+("[^"]+"|<[^>]+>)4.77
    - (0.00156s)
    24.8
    - (0.00814s)
    1.13
    - (0.000372s)
    1
    - (0.000328s)
    120
    - (0.0394s)
    1.58
    - (0.000518s)
    ^[ ]*#[ ]*include[ ]+("boost/[^"]+"|<boost/[^>]+>)4.72
    - (0.00154s)
    24.8
    - (0.00813s)
    1.12
    - (0.000367s)
    1
    - (0.000328s)
    143
    - (0.0469s)
    1.58
    - (0.000518s)
    -

    -

    -

    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. 

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ExpressionGRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    beman|john|dave4.07
    - (0.00111s)
    7.14
    - (0.00195s)
    1.75
    - (0.000479s)
    1
    - (0.000273s)
    54.3
    - (0.0149s)
    1.83
    - (0.000499s)
    <p>.*?</p>1
    - (6.59e-005s)
    1.04
    - (6.84e-005s)
    4.15
    - (0.000273s)
    4.23
    - (0.000279s)
    NA4.23
    - (0.000279s)
    <a[^>]+href=("[^"]*"|[^[:space:]]+)[^>]*>1.39
    - (0.000626s)
    1.83
    - (0.000821s)
    1.41
    - (0.000636s)
    1
    - (0.00045s)
    351
    - (0.158s)
    1.13
    - (0.000509s)
    <h[12345678][^>]*>.*?</h[12345678]>1
    - (0.000142s)
    1.21
    - (0.000171s)
    2.62
    - (0.000372s)
    1.48
    - (0.00021s)
    NA1.73
    - (0.000245s)
    <img[^>]+src=("[^"]*"|[^[:space:]]+)[^>]*>1
    - (5.38e-005s)
    1.05
    - (5.63e-005s)
    5
    - (0.000269s)
    5.18
    - (0.000278s)
    604
    - (0.0325s)
    4.05
    - (0.000218s)
    <font[^>]+face=("[^"]*"|[^[:space:]]+)[^>]*>.*?</font>1
    - (6.05e-005s)
    1.09
    - (6.59e-005s)
    4.45
    - (0.000269s)
    4.69
    - (0.000284s)
    NA3.64
    - (0.00022s)
    -

    -

    Comparison 3: Simple Matches

    -

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

    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ExpressionTextGRETAGRETA
    - (non-recursive mode)
    BoostBoost + C++ localePOSIXPCRE
    abcabc1.32
    - (2.24e-007s)
    1.86
    - (3.15e-007s)
    1.25
    - (2.12e-007s)
    1.24
    - (2.1e-007s)
    2.98
    - (5.05e-007s)
    1
    - (1.7e-007s)
    ^([0-9]+)(\-| |$)(.*)$100- this is a line of ftp response which contains a message string1.32
    - (5.91e-007s)
    1.96
    - (8.78e-007s)
    2.68
    - (1.2e-006s)
    1.53
    - (6.88e-007s)
    332
    - (0.000149s)
    1
    - (4.49e-007s)
    ([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}1234-5678-1234-4561.44
    - (7.16e-007s)
    2.04
    - (1.01e-006s)
    3.35
    - (1.66e-006s)
    2.15
    - (1.07e-006s)
    31.4
    - (1.56e-005s)
    1
    - (4.96e-007s)
    ^([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})(\]?)$john@johnmaddock.co.uk1
    - (1.18e-006s)
    1.42
    - (1.68e-006s)
    2.06
    - (2.44e-006s)
    1.35
    - (1.6e-006s)
    165
    - (0.000196s)
    1.06
    - (1.26e-006s)
    ^([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})(\]?)$foo12@foo.edu1
    - (1.09e-006s)
    1.44
    - (1.57e-006s)
    2.21
    - (2.4e-006s)
    1.41
    - (1.53e-006s)
    108
    - (0.000117s)
    1.04
    - (1.13e-006s)
    ^([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})(\]?)$bob.smith@foo.tv1
    - (1.07e-006s)
    1.43
    - (1.53e-006s)
    2.21
    - (2.37e-006s)
    1.45
    - (1.55e-006s)
    123
    - (0.000132s)
    1.05
    - (1.13e-006s)
    ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$EH10 2QQ1
    - (3.19e-007s)
    1.67
    - (5.34e-007s)
    1.58
    - (5.05e-007s)
    1.4
    - (4.49e-007s)
    10.4
    - (3.32e-006s)
    1.15
    - (3.68e-007s)
    ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$G1 1AA1
    - (3.29e-007s)
    1.65
    - (5.44e-007s)
    1.51
    - (4.96e-007s)
    1.36
    - (4.49e-007s)
    8.46
    - (2.79e-006s)
    1.1
    - (3.63e-007s)
    ^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$SW1 1ZZ1
    - (3.25e-007s)
    1.64
    - (5.34e-007s)
    1.56
    - (5.05e-007s)
    1.38
    - (4.49e-007s)
    9.29
    - (3.02e-006s)
    1.13
    - (3.68e-007s)
    ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$4/1/20011
    - (3.44e-007s)
    1.55
    - (5.34e-007s)
    2.36
    - (8.12e-007s)
    2.2
    - (7.55e-007s)
    19.6
    - (6.72e-006s)
    1.81
    - (6.21e-007s)
    ^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$12/12/20011.05
    - (6.59e-007s)
    1.66
    - (1.05e-006s)
    1.44
    - (9.07e-007s)
    1.23
    - (7.73e-007s)
    11.6
    - (7.34e-006s)
    1
    - (6.3e-007s)
    ^[-+]?[[:digit:]]*\.?[[:digit:]]*$1231
    - (5.72e-007s)
    1.59
    - (9.07e-007s)
    1.6
    - (9.16e-007s)
    1.49
    - (8.5e-007s)
    6.14
    - (3.51e-006s)
    1.22
    - (6.97e-007s)
    ^[-+]?[[:digit:]]*\.?[[:digit:]]*$+3.141591
    - (6.78e-007s)
    1.52
    - (1.03e-006s)
    1.47
    - (9.94e-007s)
    1.31
    - (8.88e-007s)
    10.8
    - (7.34e-006s)
    1.08
    - (7.35e-007s)
    ^[-+]?[[:digit:]]*\.?[[:digit:]]*$-3.141591
    - (6.78e-007s)
    1.52
    - (1.03e-006s)
    1.46
    - (9.92e-007s)
    1.32
    - (8.98e-007s)
    10.5
    - (7.11e-006s)
    1.11
    - (7.54e-007s)
    -

    -
    -

    © 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)

    - - - diff --git a/performance/Jamfile.v2 b/performance/Jamfile.v2 index ca47cb9e..38c679c9 100644 --- a/performance/Jamfile.v2 +++ b/performance/Jamfile.v2 @@ -1,56 +1,71 @@ -# copyright John Maddock 2003 -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at +# Copyright Daryle Walker, Hubert Holin, John Maddock 2006 - 2007 +# copyright Paul A. Bristow 2006 - 2010 +# Distributed under 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. +# \math_toolkit\libs\math\test\jamfile.v2 +# Runs all math toolkit tests, functions & distributions, +# and build math examples. -SOURCES = command_line main time_boost time_greta time_localised_boost time_pcre time_dynamic_xpressive time_posix time_safe_greta ; +# bring in the rules for testing +import testing ; +import modules ; +import path ; +import pch ; +using quickbook ; +using auto-index ; -local HS_REGEX_PATH = [ modules.peek : HS_REGEX_PATH ] ; -local USE_POSIX = [ modules.peek : USE_POSIX ] ; -local PCRE_PATH = [ modules.peek : PCRE_PATH ] ; -local USE_PCRE = [ modules.peek : USE_PCRE ] ; +path-constant images_location : html ; +path-constant here : . ; -if $(HS_REGEX_PATH) -{ - HS_SOURCES = $(HS_REGEX_PATH)/regcomp.c $(HS_REGEX_PATH)/regerror.c $(HS_REGEX_PATH)/regexec.c $(HS_REGEX_PATH)/regfree.c ; - POSIX_OPTS = BOOST_HAS_POSIX=1 $(HS_REGEX_PATH) ; -} -else if $(USE_POSIX) -{ - POSIX_OPTS = BOOST_HAS_POSIX=1 ; -} +lib pcre2 ; +lib regex ; +lib re2 ; -lib pcre : : pcre ; +exe has_pcre2 : config/pcre.cpp pcre2 : third_party third_party third_party release ; +explicit has_pcre2 ; +exe has_posix : config/posix.cpp : release regex ; +explicit has_posix ; +exe has_re2 : config/re2.cpp : release re2 third_party third_party third_party ; +explicit has_re2 ; -if $(PCRE_PATH) -{ - PCRE_SOURCES = $(PCRE_PATH)/chartables.c $(PCRE_PATH)/get.c $(PCRE_PATH)/pcre.c $(PCRE_PATH)/study.c ; - PCRE_OPTS = BOOST_HAS_PCRE=1 $(PCRE_PATH) ; -} -else if $(USE_PCRE) -{ - PCRE_OPTS = BOOST_HAS_PCRE=1 ; - PCRE_SOURCES = pcre ; -} +run [ glob *.cpp ] /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem + : : : + release + [ check-target-builds has_pcre2 : TEST_PCRE2 pcre2 ] + [ check-target-builds has_posix : TEST_POSIX regex ] + [ check-target-builds has_re2 : TEST_RE2 re2 third_party third_party third_party ] + third_party + third_party + third_party + : performance ; -exe regex_comparison : - $(SOURCES).cpp - $(HS_SOURCES) - $(PCRE_SOURCES) - ../build//boost_regex - ../../test/build//boost_prg_exec_monitor/static - : - BOOST_REGEX_NO_LIB=1 - BOOST_REGEX_STATIC_LINK=1 - $(POSIX_OPTS) - $(PCRE_OPTS) +xml report : doc/report.qbk : performance ; +boostbook standalone + : + report + : + # Path for links to Boost: + boost.root=../../../.. + + # Some general style settings: + table.footnote.number.format=1 + footnote.number.format=1 + html.stylesheet=../../../../doc/src/boostbook.css + + # HTML options first: + # Use graphics not text for navigation: + navig.graphics=1 + # How far down we chunk nested sections, basically all of them: + chunk.section.depth=0 + # Don't put the first section on the same page as the TOC: + chunk.first.sections=0 + # How far down sections get TOC's + toc.section.depth=2 + # Max depth in each TOC: + toc.max.depth=4 + # How far down we go with TOC's + generate.section.toc.level=10 ; - -install . : regex_comparison ; - - - - - diff --git a/performance/boost.cpp b/performance/boost.cpp new file mode 100644 index 00000000..dfff9eca --- /dev/null +++ b/performance/boost.cpp @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include "performance.hpp" +#include +#include +#include + +struct boost_regex : public abstract_regex +{ +private: + boost::regex e; + boost::cmatch what; +public: + virtual bool set_expression(const char* pe, bool isperl) + { + e.assign(pe, isperl ? boost::regex::perl : boost::regex::extended); + return e.status() == 0; + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + boost_regex::register_instance(boost::shared_ptr(new boost_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const boost_regex::initializer boost_regex::init; + + +bool boost_regex::match_test(const char * text) +{ + return regex_match(text, what, e); +} + +unsigned boost_regex::find_all(const char * text) +{ + boost::regex_iterator i(text, text + std::strlen(text), e), j; + unsigned count = 0; + while(i != j) + { + ++i; + ++count; + } + return count; +} + +std::string boost_regex::name() +{ + init.do_nothing(); + return boost_name(); +} diff --git a/performance/command_line.cpp b/performance/command_line.cpp deleted file mode 100644 index 2d2ac7ba..00000000 --- a/performance/command_line.cpp +++ /dev/null @@ -1,556 +0,0 @@ -/* - * - * Copyright (c) 2002-2003 - * John Maddock - * - * 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) - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "regex_comparison.hpp" - -#ifdef BOOST_HAS_PCRE -#include "pcre.h" // for pcre version number -#endif - -// -// globals: -// -bool time_boost = false; -bool time_localised_boost = false; -bool time_greta = false; -bool time_safe_greta = false; -bool time_posix = false; -bool time_pcre = false; -bool time_xpressive = false; -bool time_std = false; - -bool test_matches = false; -bool test_code = false; -bool test_html = false; -bool test_short_twain = false; -bool test_long_twain = false; - - -std::string html_template_file; -std::string html_out_file; -std::string html_contents; -std::list result_list; - -// the following let us compute averages: -double greta_total = 0; -double safe_greta_total = 0; -double boost_total = 0; -double locale_boost_total = 0; -double posix_total = 0; -double pcre_total = 0; -double xpressive_total = 0; -double std_total = 0; -unsigned greta_test_count = 0; -unsigned safe_greta_test_count = 0; -unsigned boost_test_count = 0; -unsigned locale_boost_test_count = 0; -unsigned posix_test_count = 0; -unsigned pcre_test_count = 0; -unsigned xpressive_test_count = 0; -unsigned std_test_count = 0; - -int handle_argument(const std::string& what) -{ - if(what == "-b") - time_boost = true; - else if(what == "-bl") - time_localised_boost = true; -#ifdef BOOST_HAS_GRETA - else if(what == "-g") - time_greta = true; - else if(what == "-gs") - time_safe_greta = true; -#endif -#ifdef BOOST_HAS_POSIX - else if(what == "-posix") - time_posix = true; -#endif -#ifdef BOOST_HAS_PCRE - else if(what == "-pcre") - time_pcre = true; -#endif -#ifdef BOOST_HAS_XPRESSIVE - else if(what == "-xpressive" || what == "-dxpr") - time_xpressive = true; -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - else if(what == "-std") - time_std = true; -#endif - else if(what == "-all") - { - time_boost = true; - time_localised_boost = true; -#ifdef BOOST_HAS_GRETA - time_greta = true; - time_safe_greta = true; -#endif -#ifdef BOOST_HAS_POSIX - time_posix = true; -#endif -#ifdef BOOST_HAS_PCRE - time_pcre = true; -#endif -#ifdef BOOST_HAS_XPRESSIVE - time_xpressive = true; -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - time_std = true; -#endif - } - else if(what == "-test-matches") - test_matches = true; - else if(what == "-test-code") - test_code = true; - else if(what == "-test-html") - test_html = true; - else if(what == "-test-short-twain") - test_short_twain = true; - else if(what == "-test-long-twain") - test_long_twain = true; - else if(what == "-test-all") - { - test_matches = true; - test_code = true; - test_html = true; - test_short_twain = true; - test_long_twain = true; - } - else if((what == "-h") || (what == "--help")) - return show_usage(); - else if((what[0] == '-') || (what[0] == '/')) - { - std::cerr << "Unknown argument: \"" << what << "\"" << std::endl; - return 1; - } - else if(html_template_file.size() == 0) - { - html_template_file = what; - load_file(html_contents, what.c_str()); - } - else if(html_out_file.size() == 0) - html_out_file = what; - else - { - std::cerr << "Unexpected argument: \"" << what << "\"" << std::endl; - return 1; - } - return 0; -} - -int show_usage() -{ - std::cout << - "Usage\n" - "regex_comparison [-h] [library options] [test options] [html_template html_output_file]\n" - " -h Show help\n\n" - " library options:\n" - " -b Apply tests to boost library\n" - " -bl Apply tests to boost library with C++ locale\n" -#ifdef BOOST_HAS_GRETA - " -g Apply tests to GRETA library\n" - " -gs Apply tests to GRETA library (in non-recursive mode)\n" -#endif -#ifdef BOOST_HAS_POSIX - " -posix Apply tests to POSIX library\n" -#endif -#ifdef BOOST_HAS_PCRE - " -pcre Apply tests to PCRE library\n" -#endif -#ifdef BOOST_HAS_XPRESSIVE - " -dxpr Apply tests to dynamic xpressive library\n" -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - " -std Apply tests to std::regex.\n" -#endif - " -all Apply tests to all libraries\n\n" - " test options:\n" - " -test-matches Test short matches\n" - " -test-code Test c++ code examples\n" - " -test-html Test c++ code examples\n" - " -test-short-twain Test short searches\n" - " -test-long-twain Test long searches\n" - " -test-all Test everthing\n"; - return 1; -} - -void load_file(std::string& text, const char* file) -{ - std::deque temp_copy; - std::ifstream is(file); - if(!is.good()) - { - std::string msg("Unable to open file: \""); - msg.append(file); - msg.append("\""); - throw std::runtime_error(msg); - } - is.seekg(0, std::ios_base::end); - std::istream::pos_type pos = is.tellg(); - is.seekg(0, std::ios_base::beg); - text.erase(); - text.reserve(pos); - std::istreambuf_iterator it(is); - std::copy(it, std::istreambuf_iterator(), std::back_inserter(text)); -} - -void print_result(std::ostream& os, double time, double best) -{ - static const char* suffixes[] = {"s", "ms", "us", "ns", "ps", }; - - if(time < 0) - { - os << "NA"; - return; - } - double rel = time / best; - bool highlight = ((rel > 0) && (rel < 1.1)); - unsigned suffix = 0; - while(time < 0) - { - time *= 1000; - ++suffix; - } - os << ""; - if(highlight) - os << ""; - if(rel <= 1000) - os << std::setprecision(3) << rel; - else - os << (int)rel; - os << "
    ("; - if(time <= 1000) - os << std::setprecision(3) << time; - else - os << (int)time; - os << suffixes[suffix] << ")"; - if(highlight) - os << "
    "; - os << ""; -} - -std::string html_quote(const std::string& in) -{ - static const boost::regex e("(<)|(>)|(&)|(\")"); - static const std::string format("(?1<)(?2>)(?3&)(?4")"); - return regex_replace(in, e, format, boost::match_default | boost::format_all); -} - -void output_html_results(bool show_description, const std::string& tagname) -{ - std::stringstream os; - if(result_list.size()) - { - // - // start by outputting the table header: - // - os << "\n"; - os << ""; - if(show_description) - os << ""; -#if defined(BOOST_HAS_GRETA) - if(time_greta == true) - os << ""; - if(time_safe_greta == true) - os << ""; -#endif - if(time_boost == true) - os << ""; - if(time_localised_boost == true) - os << ""; -#if defined(BOOST_HAS_POSIX) - if(time_posix == true) - os << ""; -#endif -#ifdef BOOST_HAS_PCRE - if(time_pcre == true) - os << ""; -#endif -#ifdef BOOST_HAS_XPRESSIVE - if(time_xpressive == true) - os << ""; -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - os << ""; -#endif - os << "\n"; - - // - // Now enumerate through all the test results: - // - std::list::const_iterator first, last; - first = result_list.begin(); - last = result_list.end(); - while(first != last) - { - os << ""; - if(show_description) - os << ""; -#if defined(BOOST_HAS_GRETA) - if(time_greta == true) - { - print_result(os, first->greta_time, first->factor); - if(first->greta_time > 0) - { - greta_total += first->greta_time / first->factor; - ++greta_test_count; - } - } - if(time_safe_greta == true) - { - print_result(os, first->safe_greta_time, first->factor); - if(first->safe_greta_time > 0) - { - safe_greta_total += first->safe_greta_time / first->factor; - ++safe_greta_test_count; - } - } -#endif - if(time_boost == true) - { - print_result(os, first->boost_time, first->factor); - if(first->boost_time > 0) - { - boost_total += first->boost_time / first->factor; - ++boost_test_count; - } - } - if(time_localised_boost == true) - { - print_result(os, first->localised_boost_time, first->factor); - if(first->localised_boost_time > 0) - { - locale_boost_total += first->localised_boost_time / first->factor; - ++locale_boost_test_count; - } - } - if(time_posix == true) - { - print_result(os, first->posix_time, first->factor); - if(first->posix_time > 0) - { - posix_total += first->posix_time / first->factor; - ++posix_test_count; - } - } -#if defined(BOOST_HAS_PCRE) - if(time_pcre == true) - { - print_result(os, first->pcre_time, first->factor); - if(first->pcre_time > 0) - { - pcre_total += first->pcre_time / first->factor; - ++pcre_test_count; - } - } -#endif -#if defined(BOOST_HAS_XPRESSIVE) - if(time_xpressive == true) - { - print_result(os, first->xpressive_time, first->factor); - if(first->xpressive_time > 0) - { - xpressive_total += first->xpressive_time / first->factor; - ++xpressive_test_count; - } - } -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - { - print_result(os, first->std_time, first->factor); - if(first->std_time > 0) - { - std_total += first->std_time / first->factor; - ++std_test_count; - } - } -#endif - os << "\n"; - ++first; - } - os << "
    ExpressionTextGRETAGRETA
    (non-recursive mode)
    BoostBoost + C++ localePOSIXPCREDynamic Xpressivestd::regex
    " << html_quote(first->expression) << "" << html_quote(first->description) << "
    \n"; - result_list.clear(); - } - else - { - os << "

    Results not available...

    \n"; - } - - std::string result = os.str(); - - std::string::size_type pos = html_contents.find(tagname); - if(pos != std::string::npos) - { - html_contents.replace(pos, tagname.size(), result); - } -} - -std::string get_boost_version() -{ - std::stringstream os; - os << (BOOST_VERSION / 100000) << '.' << ((BOOST_VERSION / 100) % 1000) << '.' << (BOOST_VERSION % 100); - return os.str(); -} - -std::string get_averages_table() -{ - std::stringstream os; - // - // start by outputting the table header: - // - os << "\n"; - os << ""; -#if defined(BOOST_HAS_GRETA) - if(time_greta == true) - { - os << ""; - } - if(time_safe_greta == true) - { - os << ""; - } - -#endif - if(time_boost == true) - { - os << ""; - } - if(time_localised_boost == true) - { - os << ""; - } -#if defined(BOOST_HAS_POSIX) - if(time_posix == true) - { - os << ""; - } -#endif -#ifdef BOOST_HAS_PCRE - if(time_pcre == true) - { - os << ""; - } -#endif -#ifdef BOOST_HAS_XPRESSIVE - if(time_xpressive == true) - { - os << ""; - } -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - { - os << ""; - } -#endif - os << "\n"; - - // - // Now enumerate through all averages: - // - os << ""; -#if defined(BOOST_HAS_GRETA) - if(time_greta == true) - os << "\n"; - if(time_safe_greta == true) - os << "\n"; -#endif -#if defined(BOOST_HAS_POSIX) - if(time_boost == true) - os << "\n"; -#endif - if(time_boost == true) - os << "\n"; - if(time_localised_boost == true) - os << "\n"; - if(time_posix == true) - os << "\n"; -#if defined(BOOST_HAS_PCRE) - if(time_pcre == true) - os << "\n"; -#endif -#if defined(BOOST_HAS_XPRESSIVE) - if(time_xpressive == true) - os << "\n"; -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - os << "\n"; -#endif - os << "\n"; - os << "
    GRETAGRETA
    (non-recursive mode)
    BoostBoost + C++ localePOSIXPCREDynamic Xpressivestd::regex
    " << (greta_total / greta_test_count) << "" << (safe_greta_total / safe_greta_test_count) << "" << (boost_total / boost_test_count) << "" << (boost_total / boost_test_count) << "" << (locale_boost_total / locale_boost_test_count) << "" << (posix_total / posix_test_count) << "" << (pcre_total / pcre_test_count) << "" << (xpressive_total / xpressive_test_count) << "" << (std_total / std_test_count) << "
    \n"; - return os.str(); -} - -void output_final_html() -{ - if(html_out_file.size()) - { - // - // start with search and replace ops: - // - std::string::size_type pos; - pos = html_contents.find("%compiler%"); - if(pos != std::string::npos) - { - html_contents.replace(pos, 10, BOOST_COMPILER); - } - pos = html_contents.find("%library%"); - if(pos != std::string::npos) - { - html_contents.replace(pos, 9, BOOST_STDLIB); - } - pos = html_contents.find("%os%"); - if(pos != std::string::npos) - { - html_contents.replace(pos, 4, BOOST_PLATFORM); - } - pos = html_contents.find("%boost%"); - if(pos != std::string::npos) - { - html_contents.replace(pos, 7, get_boost_version()); - } - pos = html_contents.find("%pcre%"); - if(pos != std::string::npos) - { -#ifdef PCRE_MINOR - html_contents.replace(pos, 6, BOOST_STRINGIZE(PCRE_MAJOR.PCRE_MINOR)); -#else - html_contents.replace(pos, 6, "N/A"); -#endif - } - pos = html_contents.find("%averages%"); - if(pos != std::string::npos) - { - html_contents.replace(pos, 10, get_averages_table()); - } - // - // now right the output to file: - // - std::ofstream os(html_out_file.c_str()); - os << html_contents; - } - else - { - std::cout << html_contents; - } -} diff --git a/performance/config/pcre.cpp b/performance/config/pcre.cpp new file mode 100644 index 00000000..36e19ea9 --- /dev/null +++ b/performance/config/pcre.cpp @@ -0,0 +1,17 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#define PCRE2_STATIC +#define PCRE2_CODE_UNIT_WIDTH 8 + +#include + +int main() +{ + pcre2_match_data* pdata = pcre2_match_data_create(30, NULL); + pcre2_match_data_free(pdata); + return 0; +} diff --git a/performance/config/posix.cpp b/performance/config/posix.cpp new file mode 100644 index 00000000..26ac6d62 --- /dev/null +++ b/performance/config/posix.cpp @@ -0,0 +1,15 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include + +int main() +{ + regex_t pe; + int r = regcomp(&pe, "foo", REG_EXTENDED); + regfree(&pe); + return r; +} diff --git a/performance/config/re2.cpp b/performance/config/re2.cpp new file mode 100644 index 00000000..98b10916 --- /dev/null +++ b/performance/config/re2.cpp @@ -0,0 +1,12 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include + +int main() +{ + return re2::RE2::FullMatch("a", "a") ? 0 : 1; +} diff --git a/performance/doc/performance_tables.qbk b/performance/doc/performance_tables.qbk new file mode 100644 index 00000000..f6454229 --- /dev/null +++ b/performance/doc/performance_tables.qbk @@ -0,0 +1,112 @@ + + +[/tables:] +[template table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[table:table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) +[[Expression[br]Text][boost 1.60][PCRE-10.10][RE2][std::regex][boost::xpressive::cregex]] +[[[^(?i)\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 1.26[br](320274ns)]][[role green 1.00[br](253424ns)]][[role blue 1.45[br](366324ns)]][[role grey -]][[role blue 3.00[br](759495ns)]]] +[[[^(?i)\u005D+face\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>.\*?<\/font>][br]In file: ../../../libs/libraries.htm][[role blue 2.94[br](198426ns)]][[role blue 1.28[br](86670ns)]][[role green 1.00[br](67463ns)]][[role grey -]][[role blue 2.92[br](197323ns)]]] +[[[^(?i)\u005D\*>.\*?<\/h\u005B12345678\u005D>][br]In file: ../../../libs/libraries.htm][[role blue 2.42[br](196304ns)]][[role blue 1.26[br](102129ns)]][[role green 1.00[br](81160ns)]][[role grey -]][[role red 5.12[br](415932ns)]]] +[[[^(?i)\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 2.87[br](196348ns)]][[role blue 1.28[br](87365ns)]][[role green 1.00[br](68502ns)]][[role grey -]][[role blue 3.25[br](222612ns)]]] +[[[^(?i)

    .\*?<\/p>][br]In file: ../../../libs/libraries.htm][[role blue 2.78[br](194346ns)]][[role blue 1.27[br](88709ns)]][[role green 1.00[br](70020ns)]][[role grey -]][[role red 4.03[br](282425ns)]]] +[[[^(\\w+)\\s\*(\\(\u005B\^()\u005D++(?:(?2)\u005B\^()\u005D++)\*+\u005B\^)\u005D\*\\))\\s\*(\\{\u005B\^{}\u005D++((?3)\u005B\^{}\u005D++)\*+\u005B\^}\u005D\*+\\})][br]In file: boost/multiprecision/number.hpp][[role green 1.00[br](1094575ns)]][[role blue 2.87[br](3136734ns)]][[role grey -]][[role grey -]][[role grey -]]] +[[[^(\^\u005B \\t\u005D\*\#(?:(?>\u005B\^\\\\\\n\u005D+)|\\\\(?>\\s\*\\n|.))\*)|][br]In file: boost/multiprecision/number.hpp][[role blue 1.92[br](11651545ns)]][[role green 1.00[br](6057879ns)]][[role grey -]][[role grey -]][[role blue 1.55[br](9388319ns)]]] +[[[^(template\u005B\u005B:space:\u005D\u005D\*<\u005B\^;:{\u005D+>\u005B\u005B:space:\u005D\u005D\*)?(class|struct)\u005B\u005B:space:\u005D\u005D\*(\\w+(\u005B \u005D\*\\(\u005B\^)\u005D\*\\))?\u005B\u0 ...][br]In file: boost/multiprecision/number.hpp][[role red 29.23[br](8736875ns)]][[role red 38.71[br](11569512ns)]][[role green 1.00[br](298862ns)]][[role red 995.92[br](297642713ns)]][[role red 27.63[br](8258368ns)]]] +[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role blue 1.60[br](153603ns)]][[role green 1.10[br](105220ns)]][[role blue 2.55[br](244839ns)]][[role red 8.53[br](819095ns)]][[role green 1.00[br](96081ns)]]] +[[[^\\w+\\s\*(\\(\u005B\^()\u005D++(?:(?1)\u005B\^()\u005D++)\*+\u005B\^)\u005D\*\\))][br]In file: boost/multiprecision/number.hpp][[role green 1.00[br](1099128ns)]][[role blue 1.66[br](1824126ns)]][[role grey -]][[role grey -]][[role grey -]]] +[[[^\\{\u005B\^{}\u005D++((?0)\u005B\^{}\u005D++)\*+\u005B\^}\u005D\*+\\}][br]In file: boost/multiprecision/number.hpp][[role blue 1.60[br](243611ns)]][[role green 1.00[br](152166ns)]][[role grey -]][[role grey -]][[role grey -]]] +[[[^\^\u005B \u005D\*\#\u005B \u005D\*include\u005B \u005D+("\u005B\^"\u005D+"|<\u005B\^>\u005D+>)][br]In file: boost/multiprecision/number.hpp][[role blue 1.54[br](260929ns)]][[role green 1.18[br](198707ns)]][[role blue 1.81[br](305923ns)]][[role red 8.53[br](1440180ns)]][[role green 1.00[br](168902ns)]]] +[[[^\^\u005B \u005D\*\#\u005B \u005D\*include\u005B \u005D+("boost\/\u005B\^"\u005D+"|\u005D+>)][br]In file: boost/multiprecision/number.hpp][[role blue 1.52[br](256685ns)]][[role green 1.17[br](198358ns)]][[role blue 1.80[br](303602ns)]][[role red 8.51[br](1438197ns)]][[role green 1.00[br](168968ns)]]] +] +] + +[template table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[table:table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) +[[Expression[br]Text][boost 1.60][std::regex]] +[[[^\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](1518659ns)]][[role red 7.17[br](10890189ns)]]] +[[[^\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](185869ns)]][[role blue 3.77[br](700484ns)]]] +[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](165840ns)]][[role red 4.95[br](820933ns)]]] +] +] + +[template table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[table:table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) +[[Expression[br]Text][boost 1.60][PCRE-10.10][RE2][std::regex][boost::xpressive::cregex]] +[[[^(\u005B\u005B:digit:\u005D\u005D{4}\u005B- \u005D){3}\u005B\u005B:digit:\u005D\u005D{3,4}][br][^1234-5678-1234-456]][[role blue 2.03[br](323ns)]][[role blue 1.25[br](198ns)]][[role green 1.00[br](159ns)]][[role red 20.73[br](3296ns)]][[role blue 1.38[br](220ns)]]] +[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role blue 1.71[br](257ns)]][[role blue 2.01[br](302ns)]][[role blue 2.38[br](357ns)]][[role red 30.81[br](4622ns)]][[role green 1.00[br](150ns)]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^bob.smith\@foo.tv]][[role blue 2.66[br](404ns)]][[role blue 2.09[br](317ns)]][[role green 1.00[br](152ns)]][[role red 38.14[br](5798ns)]][[role blue 1.87[br](284ns)]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^foo12\@foo.edu]][[role blue 2.90[br](406ns)]][[role blue 2.31[br](323ns)]][[role green 1.00[br](140ns)]][[role red 41.41[br](5797ns)]][[role blue 2.00[br](280ns)]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^john\@johnmaddock.co.uk]][[role blue 2.74[br](477ns)]][[role blue 2.17[br](378ns)]][[role green 1.00[br](174ns)]][[role red 38.15[br](6638ns)]][[role blue 2.20[br](382ns)]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role blue 1.63[br](171ns)]][[role green 1.14[br](120ns)]][[role green 1.13[br](119ns)]][[role red 34.15[br](3586ns)]][[role green 1.00[br](105ns)]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role blue 1.69[br](171ns)]][[role green 1.18[br](119ns)]][[role green 1.18[br](119ns)]][[role red 35.54[br](3590ns)]][[role green 1.00[br](101ns)]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role blue 1.60[br](149ns)]][[role green 1.15[br](107ns)]][[role green 1.10[br](102ns)]][[role red 39.99[br](3719ns)]][[role green 1.00[br](93ns)]]] +[[[^\^\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{4}\$][br][^12\/12\/2001]][[role blue 1.65[br](162ns)]][[role green 1.00[br](98ns)]][[role blue 1.31[br](128ns)]][[role red 16.57[br](1624ns)]][[role green 1.03[br](101ns)]]] +[[[^\^\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{4}\$][br][^4\/1\/2001]][[role blue 1.58[br](153ns)]][[role green 1.00[br](97ns)]][[role green 1.19[br](115ns)]][[role red 16.54[br](1604ns)]][[role green 1.02[br](99ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^EH10 2QQ]][[role blue 1.57[br](170ns)]][[role green 1.00[br](108ns)]][[role green 1.10[br](119ns)]][[role red 21.83[br](2358ns)]][[role green 1.00[br](108ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^G1 1AA]][[role blue 1.50[br](159ns)]][[role green 1.01[br](107ns)]][[role green 1.05[br](111ns)]][[role red 17.67[br](1873ns)]][[role green 1.00[br](106ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^SW1 1ZZ]][[role blue 1.53[br](164ns)]][[role green 1.00[br](107ns)]][[role green 1.07[br](115ns)]][[role red 18.05[br](1931ns)]][[role green 1.00[br](107ns)]]] +[[[^abc][br][^abc]][[role blue 2.10[br](128ns)]][[role green 1.00[br](61ns)]][[role blue 1.30[br](79ns)]][[role red 9.89[br](603ns)]][[role blue 1.25[br](76ns)]]] +] +] + + +[template table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[table:table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0) +[[Expression[br]Text][boost 1.60][std::regex]] +[[[^(\u005B\u005B:digit:\u005D\u005D{4}\u005B- \u005D){3}\u005B\u005B:digit:\u005D\u005D{3,4}][br][^1234-5678-1234-456]][[role green 1.00[br](490ns)]][[role red 6.88[br](3372ns)]]] +[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role green 1.00[br](554ns)]][[role grey -]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^bob.smith\@foo.tv]][[role green 1.00[br](614ns)]][[role grey -]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^foo12\@foo.edu]][[role green 1.00[br](596ns)]][[role grey -]]] +[[[^\^(\u005Ba-zA-Z0-9\_\\-\\.\u005D+)\@((\\\u005B\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.\u005B0-9\u005D{1,3}\\.)|((\u005Ba-zA-Z0-9\\-\u005D+\\.)+))(\u005Ba-zA-Z\u005D{2,4}|\u005B0-9\u005D{1,3})(\\ ...][br][^john\@johnmaddock.co.uk]][[role green 1.00[br](748ns)]][[role grey -]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role green 1.00[br](372ns)]][[role red 9.77[br](3635ns)]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role green 1.00[br](367ns)]][[role red 9.84[br](3613ns)]]] +[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role green 1.00[br](444ns)]][[role red 8.45[br](3754ns)]]] +[[[^\^\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{4}\$][br][^12\/12\/2001]][[role green 1.00[br](325ns)]][[role red 5.19[br](1687ns)]]] +[[[^\^\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{1,2}\/\u005B\u005B:digit:\u005D\u005D{4}\$][br][^4\/1\/2001]][[role green 1.00[br](308ns)]][[role red 5.39[br](1660ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^EH10 2QQ]][[role green 1.00[br](356ns)]][[role red 6.78[br](2415ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^G1 1AA]][[role green 1.00[br](315ns)]][[role red 6.14[br](1935ns)]]] +[[[^\^\u005Ba-zA-Z\u005D{1,2}\u005B0-9\u005D\u005B0-9A-Za-z\u005D{0,1} {0,1}\u005B0-9\u005D\u005BA-Za-z\u005D{2}\$][br][^SW1 1ZZ]][[role green 1.00[br](346ns)]][[role red 5.68[br](1967ns)]]] +[[[^abc][br][^abc]][[role green 1.00[br](287ns)]][[role blue 2.32[br](667ns)]]] +] +] + + +[/sections:] +[template section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[section:section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0)] +[table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[endsect] +] + +[template section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[section:section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0)] +[table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[endsect] +] + +[template section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[section:section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0)] +[table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[endsect] +] + + +[template section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_[] +[section:section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_ Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.0)] +[table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[endsect] +] + +[template performance_all_sections[] +[section_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[section_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[section_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[section_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +] + +[template performance_all_tables[] +[table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +[table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_0_] +] diff --git a/performance/doc/report.qbk b/performance/doc/report.qbk new file mode 100644 index 00000000..5ed00b6a --- /dev/null +++ b/performance/doc/report.qbk @@ -0,0 +1,20 @@ +[article Boost.Regex Performance Report + [quickbook 1.6] + [/purpose ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22] + [license + Distributed under 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]) + ] +] + +[import performance_tables.qbk] + +[performance_all_sections] + +[/ + Copyright 2015 John Maddock and Paul A. Bristow. + Distributed under 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). +] diff --git a/performance/input.html b/performance/input.html deleted file mode 100644 index 425dedeb..00000000 --- a/performance/input.html +++ /dev/null @@ -1,76 +0,0 @@ - - - Regular Expression Performance Comparison - - - - - - - -

    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 - up to the end of Chapter 1). 

    -

    %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)

    - - - - diff --git a/performance/main.cpp b/performance/main.cpp deleted file mode 100644 index b7ba8a52..00000000 --- a/performance/main.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include -#include -#include -#include -#include -#include "regex_comparison.hpp" - - -void test_match(const std::string& re, const std::string& text, const std::string& description, bool icase) -{ - double time; - results r(re, description); - - std::cout << "Testing: \"" << re << "\" against \"" << description << "\"" << std::endl; - -#ifdef BOOST_HAS_GRETA - if(time_greta == true) - { - time = g::time_match(re, text, icase); - r.greta_time = time; - std::cout << "\tGRETA regex: " << time << "s\n"; - } - if(time_safe_greta == true) - { - time = gs::time_match(re, text, icase); - r.safe_greta_time = time; - std::cout << "\tSafe GRETA regex: " << time << "s\n"; - } -#endif - if(time_boost == true) - { - time = b::time_match(re, text, icase); - r.boost_time = time; - std::cout << "\tBoost regex: " << time << "s\n"; - } - if(time_localised_boost == true) - { - time = bl::time_match(re, text, icase); - r.localised_boost_time = time; - std::cout << "\tBoost regex (C++ locale): " << time << "s\n"; - } -#ifdef BOOST_HAS_POSIX - if(time_posix == true) - { - time = posix::time_match(re, text, icase); - r.posix_time = time; - std::cout << "\tPOSIX regex: " << time << "s\n"; - } -#endif -#ifdef BOOST_HAS_PCRE - if(time_pcre == true) - { - time = pcr::time_match(re, text, icase); - r.pcre_time = time; - std::cout << "\tPCRE regex: " << time << "s\n"; - } -#endif -#ifdef BOOST_HAS_XPRESSIVE - if(time_xpressive == true) - { - time = dxpr::time_match(re, text, icase); - r.xpressive_time = time; - std::cout << "\txpressive regex: " << time << "s\n"; - } -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - { - time = stdr::time_match(re, text, icase); - r.std_time = time; - std::cout << "\tstd::regex: " << time << "s\n"; - } -#endif - r.finalise(); - result_list.push_back(r); -} - -void test_find_all(const std::string& re, const std::string& text, const std::string& description, bool icase) -{ - std::cout << "Testing: " << re << std::endl; - - double time; - results r(re, description); - -#ifdef BOOST_HAS_GRETA - if(time_greta == true) - { - time = g::time_find_all(re, text, icase); - r.greta_time = time; - std::cout << "\tGRETA regex: " << time << "s\n"; - } - if(time_safe_greta == true) - { - time = gs::time_find_all(re, text, icase); - r.safe_greta_time = time; - std::cout << "\tSafe GRETA regex: " << time << "s\n"; - } -#endif - if(time_boost == true) - { - time = b::time_find_all(re, text, icase); - r.boost_time = time; - std::cout << "\tBoost regex: " << time << "s\n"; - } - if(time_localised_boost == true) - { - time = bl::time_find_all(re, text, icase); - r.localised_boost_time = time; - std::cout << "\tBoost regex (C++ locale): " << time << "s\n"; - } -#ifdef BOOST_HAS_POSIX - if(time_posix == true) - { - time = posix::time_find_all(re, text, icase); - r.posix_time = time; - std::cout << "\tPOSIX regex: " << time << "s\n"; - } -#endif -#ifdef BOOST_HAS_PCRE - if(time_pcre == true) - { - time = pcr::time_find_all(re, text, icase); - r.pcre_time = time; - std::cout << "\tPCRE regex: " << time << "s\n"; - } -#endif -#ifdef BOOST_HAS_XPRESSIVE - if(time_xpressive == true) - { - time = dxpr::time_find_all(re, text, icase); - r.xpressive_time = time; - std::cout << "\txpressive regex: " << time << "s\n"; - } -#endif -#ifndef BOOST_NO_CXX11_HDR_REGEX - if(time_std == true) - { - time = stdr::time_find_all(re, text, icase); - r.std_time = time; - std::cout << "\tstd::regex: " << time << "s\n"; - } -#endif - r.finalise(); - result_list.push_back(r); -} - -int cpp_main(int argc, char * argv[]) -{ - // start by processing the command line args: - if(argc < 2) - return show_usage(); - int result = 0; - for(int c = 1; c < argc; ++c) - { - result += handle_argument(argv[c]); - } - if(result) - return result; - - if(test_matches) - { - // start with a simple test, this is basically a measure of the minimal overhead - // involved in calling a regex matcher: - test_match("abc", "abc"); - // these are from the regex docs: - test_match("^([0-9]+)(\\-| |$)(.*)$", "100- this is a line of ftp response which contains a message string"); - test_match("([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}", "1234-5678-1234-456"); - // these are from http://www.regxlib.com/ - test_match("^([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})(\\]?)$", "john@johnmaddock.co.uk"); - test_match("^([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})(\\]?)$", "foo12@foo.edu"); - test_match("^([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})(\\]?)$", "bob.smith@foo.tv"); - test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "EH10 2QQ"); - test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "G1 1AA"); - test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "SW1 1ZZ"); - test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "4/1/2001"); - test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "12/12/2001"); - test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "123"); - test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "+3.14159"); - test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "-3.14159"); - } - output_html_results(true, "%short_matches%"); - - std::string file_contents; - - if(test_code) - { - load_file(file_contents, "../../../boost/crc.hpp"); - - const char* highlight_expression = // preprocessor directives: index 1 - "(^[ \t]*#(?:[^\\\\\\n]|\\\\[^\\n_[:punct:][:alnum:]]*[\\n[:punct:][:word:]])*)|" - // comment: index 2 - "(//[^\\n]*|/\\*.*?\\*/)|" - // literals: index 3 - "\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|" - // string literals: index 4 - "('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|" - // keywords: index 5 - "\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import" - "|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall" - "|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool" - "|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete" - "|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto" - "|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected" - "|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast" - "|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned" - "|using|virtual|void|volatile|wchar_t|while)\\>" - ; - - const char* class_expression = "^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?" - "(class|struct)[[:space:]]*(\\<\\w+\\>([ \t]*\\([^)]*\\))?" - "[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?" - "(\\{|:[^;\\{()]*\\{)"; - - const char* include_expression = "^[ \t]*#[ \t]*include[ \t]+(\"[^\"]+\"|<[^>]+>)"; - const char* boost_include_expression = "^[ \t]*#[ \t]*include[ \t]+(\"boost/[^\"]+\"|]+>)"; - - - test_find_all(class_expression, file_contents); - test_find_all(highlight_expression, file_contents); - test_find_all(include_expression, file_contents); - test_find_all(boost_include_expression, file_contents); - } - output_html_results(false, "%code_search%"); - - if(test_html) - { - load_file(file_contents, "../../../libs/libraries.htm"); - test_find_all("beman|john|dave", file_contents, true); - test_find_all("

    .*?

    ", file_contents, true); - test_find_all("]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents, true); - test_find_all("]*>.*?", file_contents, true); - test_find_all("]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents, true); - test_find_all("]+face=(\"[^\"]*\"|[^[:space:]]+)[^>]*>.*?", file_contents, true); - } - output_html_results(false, "%html_search%"); - - if(test_short_twain) - { - load_file(file_contents, "short_twain.txt"); - - test_find_all("Twain", file_contents); - test_find_all("Huck[[:alpha:]]+", file_contents); - test_find_all("[[:alpha:]]+ing", file_contents); - test_find_all("^[^\n]*?Twain", file_contents); - test_find_all("Tom|Sawyer|Huckleberry|Finn", file_contents); - test_find_all("(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)", file_contents); - } - output_html_results(false, "%short_twain_search%"); - - if(test_long_twain) - { - load_file(file_contents, "mtent13.txt"); - - test_find_all("Twain", file_contents); - test_find_all("Huck[[:alpha:]]+", file_contents); - test_find_all("[[:alpha:]]+ing", file_contents); - test_find_all("^[^\n]*?Twain", file_contents); - test_find_all("Tom|Sawyer|Huckleberry|Finn", file_contents); - time_posix = false; - test_find_all("(Tom|Sawyer|Huckleberry|Finn).{0,30}river|river.{0,30}(Tom|Sawyer|Huckleberry|Finn)", file_contents); - time_posix = true; - } - output_html_results(false, "%long_twain_search%"); - - output_final_html(); - return 0; -} - - diff --git a/performance/pcre.cpp b/performance/pcre.cpp new file mode 100644 index 00000000..878a5cad --- /dev/null +++ b/performance/pcre.cpp @@ -0,0 +1,95 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#ifdef TEST_PCRE2 + +#define PCRE2_STATIC +#define PCRE2_CODE_UNIT_WIDTH 8 + +#include "performance.hpp" +#include +#include +#include + +struct pcre_regex : public abstract_regex +{ +private: + pcre2_code* pe; + pcre2_match_data* pdata; +public: + pcre_regex() + : pe(0) + { + pdata = pcre2_match_data_create(30, NULL); + } + ~pcre_regex() + { + if(pe) + pcre2_code_free(pe); + pcre2_match_data_free(pdata); + } + virtual bool set_expression(const char* pat, bool isperl) + { + if(!isperl) + return false; + if(pe) + pcre2_code_free(pe); + int errorcode = 0; + PCRE2_SIZE erroroffset; + pe = pcre2_compile((PCRE2_SPTR)pat, std::strlen(pat), PCRE2_MULTILINE, &errorcode, &erroroffset, NULL); + return pe ? true : false; + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + pcre_regex::register_instance(boost::shared_ptr(new pcre_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const pcre_regex::initializer pcre_regex::init; + + +bool pcre_regex::match_test(const char * text) +{ + int r = pcre2_match(pe, (PCRE2_SPTR)text, std::strlen(text), 0, PCRE2_ANCHORED, pdata, NULL); + return r >= 0; +} + +unsigned pcre_regex::find_all(const char * text) +{ + unsigned count = 0; + int flags = 0; + const char* end = text + std::strlen(text); + while(pcre2_match(pe, (PCRE2_SPTR)text, end - text, 0, flags, pdata, NULL) >= 0) + { + ++count; + PCRE2_SIZE* v = pcre2_get_ovector_pointer(pdata); + text += v[1]; + if(v[0] == v[1]) + ++text; + if(*text) + { + flags = *(text - 1) == '\n' ? 0 : PCRE2_NOTBOL; + } + } + return count; +} + +std::string pcre_regex::name() +{ + init.do_nothing(); + return std::string("PCRE-") + boost::lexical_cast(PCRE2_MAJOR) + "." + boost::lexical_cast(PCRE2_MINOR); +} + +#endif diff --git a/performance/performance.cpp b/performance/performance.cpp new file mode 100644 index 00000000..a67ff9b5 --- /dev/null +++ b/performance/performance.cpp @@ -0,0 +1,256 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include "performance.hpp" +#include +#include +#include +#include +#include + +void load_file(std::string& text, const char* file) +{ + std::deque temp_copy; + std::ifstream is(file); + if(!is.good()) + { + std::string msg("Unable to open file: \""); + msg.append(file); + msg.append("\""); + throw std::runtime_error(msg); + } + is.seekg(0, std::ios_base::end); + std::istream::pos_type pos = is.tellg(); + is.seekg(0, std::ios_base::beg); + text.erase(); + text.reserve(pos); + std::istreambuf_iterator it(is); + std::copy(it, std::istreambuf_iterator(), std::back_inserter(text)); +} + + +typedef std::list > list_type; + +list_type& engines() +{ + static list_type l; + return l; +} + +void abstract_regex::register_instance(boost::shared_ptr item) +{ + engines().push_back(item); +} + +template +struct stopwatch +{ + typedef typename Clock::duration duration; + stopwatch() + { + m_start = Clock::now(); + } + duration elapsed() + { + return Clock::now() - m_start; + } + void reset() + { + m_start = Clock::now(); + } + +private: + typename Clock::time_point m_start; +}; + +unsigned sum = 0; +unsigned last_value_returned = 0; + +template +double exec_timed_test(Func f) +{ + double t = 0; + unsigned repeats = 1; + do { + stopwatch w; + + for(unsigned count = 0; count < repeats; ++count) + { + last_value_returned = f(); + sum += last_value_returned; + } + + t = boost::chrono::duration_cast>(w.elapsed()).count(); + if(t < 0.5) + repeats *= 2; + } while(t < 0.5); + return t / repeats; +} + + +std::string format_expression_as_quickbook(std::string s) +{ + static const boost::regex e("[`/_*=$^@#&%\\\\]"); + static const boost::regex open_b("\\["); + static const boost::regex close_b("\\]"); + s = regex_replace(s, e, "\\\\$0"); + s = regex_replace(s, open_b, "\\\\u005B"); + s = regex_replace(s, close_b, "\\\\u005D"); + if(s.size() > 200) + { + s.erase(200); + s += " ..."; + } + return "[^" + s + "]"; +} + +void test_match(const char* expression, const char* text, bool isperl = false) +{ + std::string table = "Testing simple " + (isperl ? std::string("Perl") : std::string("leftmost-longest")) + " matches (platform = " + platform_name() + ", compiler = " + compiler_name() + ")"; + std::string row = format_expression_as_quickbook(expression); + row += "[br]"; + row += format_expression_as_quickbook(text); + for(list_type::const_iterator i = engines().begin(); i != engines().end(); ++i) + { + std::string heading = (*i)->name(); + if((*i)->set_expression(expression, isperl)) + { + double time = exec_timed_test([&]() { return (*i)->match_test(text) ? 1 : 0; }); + report_execution_time(time, table, row, heading); + } + } +} + +void test_search(const char* expression, const char* text, bool isperl = false, const char* filename = 0) +{ + std::string table = "Testing " + (isperl ? std::string("Perl") : std::string("leftmost-longest")) + " searches (platform = " + platform_name() + ", compiler = " + compiler_name() + ")"; + std::string row = format_expression_as_quickbook(expression); + row += "[br]"; + if(filename) + { + row += "In file: "; + row += filename; + } + else + { + row += format_expression_as_quickbook(text); + } + for(list_type::const_iterator i = engines().begin(); i != engines().end(); ++i) + { + std::string heading = (*i)->name(); + if((*i)->set_expression(expression, isperl)) + { + double time = exec_timed_test([&]() { return (*i)->find_all(text); }); + report_execution_time(time, table, row, heading); + std::cout << "Search with library: " << heading << " found " << last_value_returned << " occurances.\n"; + } + } +} + +int cpp_main(int argc, char* argv[]) +{ + boost::filesystem::path here(__FILE__); + here = here.parent_path().parent_path().parent_path().parent_path(); + + boost::filesystem::path cpp_file = here / "boost"; + cpp_file /= "crc.hpp"; + + // start with a simple test, this is basically a measure of the minimal overhead + // involved in calling a regex matcher: + test_match("abc", "abc"); + // these are from the regex docs: + test_match("^([0-9]+)(\\-| |$)(.*)$", "100- this is a line of ftp response which contains a message string"); + test_match("([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}", "1234-5678-1234-456"); + // these are from http://www.regxlib.com/ + test_match("^([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})(\\]?)$", "john@johnmaddock.co.uk"); + test_match("^([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})(\\]?)$", "foo12@foo.edu"); + test_match("^([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})(\\]?)$", "bob.smith@foo.tv"); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "EH10 2QQ"); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "G1 1AA"); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "SW1 1ZZ"); + test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "4/1/2001"); + test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "12/12/2001"); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "123"); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "+3.14159"); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "-3.14159"); + + // start with a simple test, this is basically a measure of the minimal overhead + // involved in calling a regex matcher: + test_match("abc", "abc", true); + // these are from the regex docs: + test_match("^([0-9]+)(\\-| |$)(.*)$", "100- this is a line of ftp response which contains a message string", true); + test_match("([[:digit:]]{4}[- ]){3}[[:digit:]]{3,4}", "1234-5678-1234-456", true); + // these are from http://www.regxlib.com/ + test_match("^([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})(\\]?)$", "john@johnmaddock.co.uk", true); + test_match("^([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})(\\]?)$", "foo12@foo.edu", true); + test_match("^([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})(\\]?)$", "bob.smith@foo.tv", true); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "EH10 2QQ", true); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "G1 1AA", true); + test_match("^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$", "SW1 1ZZ", true); + test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "4/1/2001", true); + test_match("^[[:digit:]]{1,2}/[[:digit:]]{1,2}/[[:digit:]]{4}$", "12/12/2001", true); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "123", true); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "+3.14159", true); + test_match("^[-+]?[[:digit:]]*\\.?[[:digit:]]*$", "-3.14159", true); + + std::string file_contents; + + const char* highlight_expression = // preprocessor directives: index 1 + "(^[ \\t]*#(?:(?>[^\\\\\\n]+)|\\\\(?>\\s*\\n|.))*)|"; + // comment: index 2 + "(//[^\\n]*|/\\*.*?\\*/)|" + // literals: index 3 + "\\<([+-]?(?:(?:0x[[:xdigit:]]+)|(?:(?:[[:digit:]]*\\.)?[[:digit:]]+(?:[eE][+-]?[[:digit:]]+)?))u?(?:(?:int(?:8|16|32|64))|L)?)\\>|" + // string literals: index 4 + "('(?:[^\\\\']|\\\\.)*'|\"(?:[^\\\\\"]|\\\\.)*\")|" + // keywords: index 5 + "\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import" + "|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall" + "|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool" + "|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete" + "|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto" + "|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected" + "|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast" + "|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned" + "|using|virtual|void|volatile|wchar_t|while)\\>" + ; + const char* class_expression = "(template[[:space:]]*<[^;:{]+>[[:space:]]*)?" + "(class|struct)[[:space:]]*(\\w+([ \t]*\\([^)]*\\))?" + "[[:space:]]*)*(\\w*)[[:space:]]*(<[^;:{]+>[[:space:]]*)?" + "(\\{|:[^;\\{()]*\\{)"; + const char* call_expression = "\\w+\\s*(\\([^()]++(?:(?1)[^()]++)*+[^)]*\\))"; + + const char* include_expression = "^[ \t]*#[ \t]*include[ \t]+(\"[^\"]+\"|<[^>]+>)"; + const char* boost_include_expression = "^[ \t]*#[ \t]*include[ \t]+(\"boost/[^\"]+\"|]+>)"; + const char* brace_expression = "\\{[^{}]++((?0)[^{}]++)*+[^}]*+\\}"; + const char* function_with_body_expression = "(\\w+)\\s*(\\([^()]++(?:(?2)[^()]++)*+[^)]*\\))\\s*(\\{[^{}]++((?3)[^{}]++)*+[^}]*+\\})"; + + + load_file(file_contents, "../../../libs/libraries.htm"); + test_search("Beman|John|Dave", file_contents.c_str(), false, "../../../libs/libraries.htm"); + test_search("Beman|John|Dave", file_contents.c_str(), true, "../../../libs/libraries.htm"); + test_search("(?i)

    .*?

    ", file_contents.c_str(), true, "../../../libs/libraries.htm"); + test_search("]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), false, "../../../libs/libraries.htm"); + test_search("(?i)]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), true, "../../../libs/libraries.htm"); + test_search("(?i)]*>.*?", file_contents.c_str(), true, "../../../libs/libraries.htm"); + test_search("]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), false, "../../../libs/libraries.htm"); + test_search("(?i)]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), true, "../../../libs/libraries.htm"); + test_search("(?i)]+face=(\"[^\"]*\"|[^[:space:]]+)[^>]*>.*?", file_contents.c_str(), true, "../../../libs/libraries.htm"); + + + load_file(file_contents, "../../../boost/multiprecision/number.hpp"); + + test_search(function_with_body_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(brace_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(call_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(highlight_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(class_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(include_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + test_search(boost_include_expression, file_contents.c_str(), true, "boost/multiprecision/number.hpp"); + + return 0; +} + diff --git a/performance/performance.hpp b/performance/performance.hpp new file mode 100644 index 00000000..627065a6 --- /dev/null +++ b/performance/performance.hpp @@ -0,0 +1,30 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#ifndef BOOST_REGEX_PERFRMANCE_HPP +#define BOOST_REGEX_PERFRMANCE_HPP + +#include +#include + +struct abstract_regex +{ + virtual bool set_expression(const char*, bool isperl) = 0; + virtual bool match_test(const char* text) = 0; + virtual unsigned find_all(const char* text) = 0; + virtual std::string name() = 0; + static void register_instance(boost::shared_ptr item); +}; + +void report_execution_time(double t, std::string table, std::string row, std::string heading); +std::string boost_name(); +std::string compiler_name(); +std::string platform_name(); + + +#endif + + diff --git a/performance/posix.cpp b/performance/posix.cpp new file mode 100644 index 00000000..4e0eea70 --- /dev/null +++ b/performance/posix.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#ifdef TEST_POSIX + +#include "performance.hpp" +#include + +#include + +struct posix_regex : public abstract_regex +{ +private: + regex_t pe, pe2; + bool init; +public: + posix_regex() : pe, init(false) {} + ~posix_regex() + { + if(init) + { + regfree(&pe); + regfree(&pe2); + } + } + virtual bool set_expression(const char* pat, bool isperl) + { + if(isperl) + return false; + if(init) + { + regfree(&pe); + regfree(&pe2); + } + else + init = true; + int r = regcomp(&pe, pat, REG_EXTENDED); + std::string s(pat); + if(s.size() && (s[0] != '^')) + s.insert(0, 1, '^'); + if(s.size() && (*s.rbegin() != '$')) + s.append("$"); + r |= regcomp(&pe2, s.c_str(), REG_EXTENDED); + return r ? false : true; + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + posix_regex::register_instance(boost::shared_ptr(new posix_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const posix_regex::initializer posix_regex::init; + + +bool posix_regex::match_test(const char * text) +{ + regmatch_t m[30]; + int r = regexec(&pe2, text, 30, m, 0); + return r == 0; +} + +unsigned posix_regex::find_all(const char * text) +{ + unsigned count = 0; + regmatch_t m[30]; + int flags = 0; + while(regexec(&pe, text, 30, m, flags) == 0) + { + ++count; + text = m[0].rm_so; + if(*text) + ++text; + flags = REG_NOTBOL; + } + return 0; +} + +std::string posix_regex::name() +{ + init.do_nothing(); + return "POSIX"; +} + +#endif diff --git a/performance/re2.cpp b/performance/re2.cpp new file mode 100644 index 00000000..2ddf1aaf --- /dev/null +++ b/performance/re2.cpp @@ -0,0 +1,71 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#ifdef TEST_RE2 + +#include "performance.hpp" +#include +#include + +using namespace re2; + +struct re2_regex : public abstract_regex +{ +private: + boost::scoped_ptr pat; +public: + re2_regex() {} + ~re2_regex(){} + virtual bool set_expression(const char* pp, bool isperl) + { + if(!isperl) + return false; + std::string s("(?m)"); + s += pp; + pat.reset(new RE2(s)); + return pat->ok(); + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + re2_regex::register_instance(boost::shared_ptr(new re2_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const re2_regex::initializer re2_regex::init; + + +bool re2_regex::match_test(const char * text) +{ + return RE2::FullMatch(text, *pat); +} + +unsigned re2_regex::find_all(const char * text) +{ + unsigned count = 0; + StringPiece input(text); + while(RE2::FindAndConsume(&input, *pat)) + { + ++count; + } + return count; +} + +std::string re2_regex::name() +{ + init.do_nothing(); + return "RE2"; +} + +#endif diff --git a/performance/regex_comparison.hpp b/performance/regex_comparison.hpp deleted file mode 100644 index 4ed968fd..00000000 --- a/performance/regex_comparison.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - - -#ifndef REGEX_COMPARISON_HPP -#define REGEX_COMPARISON_HPP - -#include -#include -#include - -// -// globals: -// -extern bool time_boost; -extern bool time_localised_boost; -extern bool time_greta; -extern bool time_safe_greta; -extern bool time_posix; -extern bool time_pcre; -extern bool time_xpressive; -extern bool time_std; - -extern bool test_matches; -extern bool test_short_twain; -extern bool test_long_twain; -extern bool test_code; -extern bool test_html; - -extern std::string html_template_file; -extern std::string html_out_file; -extern std::string html_contents; - - -int handle_argument(const std::string& what); -int show_usage(); -void load_file(std::string& text, const char* file); -void output_html_results(bool show_description, const std::string& tagname); -void output_final_html(); - - -struct results -{ - double boost_time; - double localised_boost_time; - double greta_time; - double safe_greta_time; - double posix_time; - double pcre_time; - double xpressive_time; - double std_time; - double factor; - std::string expression; - std::string description; - results(const std::string& ex, const std::string& desc) - : boost_time(-1), - localised_boost_time(-1), - greta_time(-1), - safe_greta_time(-1), - posix_time(-1), - pcre_time(-1), - xpressive_time(-1), - std_time(-1), - factor((std::numeric_limits::max)()), - expression(ex), - description(desc) - {} - void finalise() - { - if((boost_time >= 0) && (boost_time < factor)) - factor = boost_time; - if((localised_boost_time >= 0) && (localised_boost_time < factor)) - factor = localised_boost_time; - if((greta_time >= 0) && (greta_time < factor)) - factor = greta_time; - if((safe_greta_time >= 0) && (safe_greta_time < factor)) - factor = safe_greta_time; - if((posix_time >= 0) && (posix_time < factor)) - factor = posix_time; - if((pcre_time >= 0) && (pcre_time < factor)) - factor = pcre_time; - if((xpressive_time >= 0) && (xpressive_time < factor)) - factor = xpressive_time; - if((std_time >= 0) && (std_time < factor)) - factor = std_time; - } -}; - -extern std::list result_list; - - -namespace b { -// boost tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace bl { -// localised boost tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace pcr { -// pcre tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace g { -// greta tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace gs { -// safe greta tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace posix { -// safe greta tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); - -} -namespace dxpr { -// xpressive tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); -} -namespace stdr { -// xpressive tests: -double time_match(const std::string& re, const std::string& text, bool icase); -double time_find_all(const std::string& re, const std::string& text, bool icase); -} - -void test_match(const std::string& re, const std::string& text, const std::string& description, bool icase = false); -void test_find_all(const std::string& re, const std::string& text, const std::string& description, bool icase = false); -inline void test_match(const std::string& re, const std::string& text, bool icase = false) -{ test_match(re, text, text, icase); } -inline void test_find_all(const std::string& re, const std::string& text, bool icase = false) -{ test_find_all(re, text, "", icase); } - - -#define REPEAT_COUNT 10 - -#endif - diff --git a/performance/std.cpp b/performance/std.cpp new file mode 100644 index 00000000..9294acef --- /dev/null +++ b/performance/std.cpp @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include + +#ifndef BOOST_NO_CXX11_HDR_REGEX + +#include "performance.hpp" +#include + +struct std_regex : public abstract_regex +{ +private: + std::regex e; + std::cmatch what; +public: + virtual bool set_expression(const char* pe, bool isperl) + { + try + { + e.assign(pe, isperl ? std::regex::ECMAScript : std::regex::extended); + } + catch(const std::exception&) + { + return false; + } + return true; + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + std_regex::register_instance(boost::shared_ptr(new std_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const std_regex::initializer std_regex::init; + + +bool std_regex::match_test(const char * text) +{ + return regex_match(text, what, e); +} + +unsigned std_regex::find_all(const char * text) +{ + std::regex_iterator i(text, text + std::strlen(text), e), j; + unsigned count = 0; + while(i != j) + { + ++i; + ++count; + } + return count; +} + +std::string std_regex::name() +{ + init.do_nothing(); + return "std::regex"; +} + +#endif diff --git a/performance/table_helper.cpp b/performance/table_helper.cpp new file mode 100644 index 00000000..5197c203 --- /dev/null +++ b/performance/table_helper.cpp @@ -0,0 +1,413 @@ +// Copyright John Maddock 2015. +// 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) + +#ifdef _MSC_VER +# pragma warning (disable : 4224) +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +std::vector > data; + +inline std::string sanitize_string(const std::string& s) +{ + static const boost::regex e("[^a-zA-Z0-9]+"); + std::string result = boost::regex_replace(s, e, "_"); + while(result[0] == '_') + result.erase(0); + return result; +} + +std::string format_precision(double val, int digits) +{ + std::stringstream ss; + ss << std::setprecision(digits); + ss << std::fixed; + ss << val; + return ss.str(); +} + +static std::string content; +boost::filesystem::path path_to_content; + +struct content_loader +{ + content_loader() + { + boost::filesystem::path p(__FILE__); + p = p.parent_path(); + p /= "doc"; + p /= "performance_tables.qbk"; + path_to_content = p; + if(boost::filesystem::exists(p)) + { + boost::filesystem::ifstream is(p); + if(is.good()) + { + do + { + char c = static_cast(is.get()); + if(c != EOF) + content.append(1, c); + } while(is.good()); + } + } + } + ~content_loader() + { + boost::filesystem::ofstream os(path_to_content); + os << content; + } + void instantiate()const + { + } +}; + +static const content_loader loader; + +void load_table(std::vector >& table, std::string::const_iterator begin, std::string::const_iterator end) +{ + static const boost::regex item_e( + "\\[" + "([^\\[\\]]*(?0)?)*" + "\\]" + ); + + boost::regex_token_iterator i(begin, end, item_e), j; + + while(i != j) + { + // Add a row: + table.push_back(std::vector()); + boost::regex_token_iterator k(i->first + 1, i->second - 1, item_e); + while(k != j) + { + // Add a cell: + table.back().push_back(std::string(k->first + 1, k->second - 1)); + ++k; + } + ++i; + } +} + +std::string save_table(std::vector >& table) +{ + std::string result; + + for(std::vector >::const_iterator i = table.begin(), j = table.end(); i != j; ++i) + { + result += "["; + for(std::vector::const_iterator k = i->begin(), l = i->end(); k != l; ++k) + { + result += "["; + result += *k; + result += "]"; + } + result += "]\n"; + } + return result; +} + +void add_to_all_sections(const std::string& id, std::string list_name = "performance_all_sections") +{ + std::string::size_type pos = content.find("[template " + list_name + "[]"), end_pos; + if(pos == std::string::npos) + { + // + // Just append to the end: + // + content.append("\n[template ").append(list_name).append("[]\n[").append(id).append("]\n]\n"); + } + else + { + // + // Read in the all list of sections, add our new one (in alphabetical order), + // and then rewrite the whole thing: + // + static const boost::regex item_e( + "\\[" + "((?=[^\\]])[^\\[\\]]*+(?0)?+)*+" + "\\]|\\]" + ); + boost::regex_token_iterator i(content.begin() + pos + 12 + list_name.size(), content.end(), item_e), j; + std::set sections; + while(i != j) + { + if(i->length() == 1) + { + end_pos = i->first - content.begin(); + break; + } + sections.insert(std::string(i->first + 1, i->second - 1)); + ++i; + } + sections.insert(id); + std::string new_list = "\n"; + for(std::set::const_iterator sec = sections.begin(); sec != sections.end(); ++sec) + { + new_list += "[" + *sec + "]\n"; + } + content.replace(pos + 12 + list_name.size(), end_pos - pos - 12 - list_name.size(), new_list); + } +} + +std::string get_colour(boost::uintmax_t val, boost::uintmax_t best) +{ + if(val <= best * 1.2) + return "green"; + if(val > best * 4) + return "red"; + return "blue"; +} + +boost::intmax_t get_value_from_cell(const std::string& cell) +{ + static const boost::regex time_e("(\\d+)ns"); + boost::smatch what; + if(regex_search(cell, what, time_e)) + { + return boost::lexical_cast(what.str(1)); + } + return -1; +} + +void add_cell(boost::intmax_t val, const std::string& table_name, const std::string& row_name, const std::string& column_heading) +{ + // + // Load the table, add our data, and re-write: + // + std::string table_id = "table_" + sanitize_string(table_name); + boost::regex table_e("\\[table:" + table_id + + "\\s(?:[^\\[]|\\\\.)++" + "((\\[" + "((?:[^\\[\\]]|\\\\.)*+(?2)?+)*+" + "\\]\\s*+)*+\\s*+)" + "\\]" + ); + + boost::smatch table_location; + if(regex_search(content, table_location, table_e)) + { + std::vector > table_data; + load_table(table_data, table_location[1].first, table_location[1].second); + // + // Figure out which column we're on: + // + unsigned column_id = 1001u; + for(unsigned i = 0; i < table_data[0].size(); ++i) + { + if(table_data[0][i] == column_heading) + { + column_id = i; + break; + } + } + if(column_id > 1000) + { + // + // Need a new column, must be adding a new compiler to the table! + // + table_data[0].push_back(column_heading); + for(unsigned i = 1; i < table_data.size(); ++i) + table_data[i].push_back(std::string()); + column_id = table_data[0].size() - 1; + } + // + // Figure out the row: + // + unsigned row_id = 1001; + for(unsigned i = 1; i < table_data.size(); ++i) + { + if(table_data[i][0] == row_name) + { + row_id = i; + break; + } + } + if(row_id > 1000) + { + // + // Need a new row, add it now: + // + table_data.push_back(std::vector()); + table_data.back().push_back(row_name); + for(unsigned i = 1; i < table_data[0].size(); ++i) + table_data.back().push_back(std::string()); + row_id = table_data.size() - 1; + } + // + // Find the best result in this row: + // + boost::uintmax_t best = (std::numeric_limits::max)(); + std::vector values; + for(unsigned i = 1; i < table_data[row_id].size(); ++i) + { + if(i == column_id) + { + if(val < best) + best = val; + values.push_back(val); + } + else + { + std::cout << "Existing cell value was " << table_data[row_id][i] << std::endl; + boost::uintmax_t cell_val = get_value_from_cell(table_data[row_id][i]); + std::cout << "Extracted value: " << cell_val << std::endl; + if(cell_val < best) + best = cell_val; + values.push_back(cell_val); + } + } + // + // Update the row: + // + for(unsigned i = 1; i < table_data[row_id].size(); ++i) + { + std::string& s = table_data[row_id][i]; + s = "[role "; + if(values[i - 1] < 0) + { + s += "grey -]"; + } + else + { + s += get_colour(values[i - 1], best); + s += " "; + s += format_precision(static_cast(values[i - 1]) / best, 2); + s += "[br]("; + s += boost::lexical_cast(values[i - 1]) + "ns)]"; + } + } + // + // Convert back to a string and insert into content: + std::sort(table_data.begin() + 1, table_data.end(), [](std::vector const& a, std::vector const& b) { return a[0] < b[0]; } ); + std::string c = save_table(table_data); + content.replace(table_location.position(1), table_location.length(1), c); + } + else + { + // + // Create a new table and try again: + // + std::string new_table = "\n[template " + table_id; + new_table += "[]\n[table:" + table_id; + new_table += " "; + new_table += table_name; + new_table += "\n[[Expression[br]Text]["; + new_table += column_heading; + new_table += "]]\n"; + new_table += "[["; + new_table += row_name; + new_table += "][[role blue 1.00[br]("; + new_table += boost::lexical_cast(val); + new_table += "ns)]]]\n]\n]\n"; + + std::string::size_type pos = content.find("[/tables:]"); + if(pos != std::string::npos) + content.insert(pos + 10, new_table); + else + content += "\n\n[/tables:]\n" + new_table; + // + // Add a section for this table as well: + // + std::string section_id = "section_" + sanitize_string(table_name); + if(content.find(section_id + "[]") == std::string::npos) + { + std::string new_section = "\n[template " + section_id + "[]\n[section:" + section_id + " " + table_name + "]\n[" + table_id + "]\n[endsect]\n]\n"; + pos = content.find("[/sections:]"); + if(pos != std::string::npos) + content.insert(pos + 12, new_section); + else + content += "\n\n[/sections:]\n" + new_section; + add_to_all_sections(section_id); + } + // + // Add to list of all tables (not in sections): + // + add_to_all_sections(table_id, "performance_all_tables"); + } +} + +void report_execution_time(double t, std::string table, std::string row, std::string heading) +{ + try { + add_cell(static_cast(t / 1e-9), table, row, heading); + } + catch(const std::exception& e) + { + std::cout << "Error in adding cell: " << e.what() << std::endl; + throw; + } +} + +std::string boost_name() +{ + return "boost " + boost::lexical_cast(BOOST_VERSION / 100000) + "." + boost::lexical_cast((BOOST_VERSION / 100) % 1000); +} + +std::string compiler_name() +{ +#ifdef COMPILER_NAME + return COMPILER_NAME; +#else + return BOOST_COMPILER; +#endif +} + +std::string platform_name() +{ +#ifdef _WIN32 + return "Windows x64"; +#else + return BOOST_PLATFORM; +#endif +} + + +std::string get_compiler_options_name() +{ +#if defined(BOOST_MSVC) || defined(__ICL) + std::string result; +#ifdef BOOST_MSVC + result = "cl "; +#else + result = "icl "; +#endif +#ifdef _M_AMD64 +#ifdef __AVX__ + result += "/arch:AVX /Ox"; +#else + result += "/Ox"; +#endif + result += " (x64 build)"; +#else +#ifdef _DEBUG + result += "/Od"; +#elif defined(__AVX2__) + result += "/arch:AVX2 /Ox"; +#elif defined(__AVX__) + result += "/arch:AVX /Ox"; +#elif _M_IX86_FP == 2 + result += "/arch:sse2 /Ox"; +#else + result += "/arch:ia32 /Ox"; +#endif + result += " (x86 build)"; +#endif + std::cout << "Compiler options are found as: " << result << std::endl; + return result; +#else + return "Unknown"; +#endif +} + diff --git a/performance/time_boost.cpp b/performance/time_boost.cpp deleted file mode 100644 index 8d145396..00000000 --- a/performance/time_boost.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" -#include -#include -#include - -namespace b{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - try{ - boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); - boost::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_match(text, what, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_match(text, what, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -bool dummy_grep_proc(const boost::smatch&) -{ return true; } - -struct noop -{ - void operator()( boost::smatch const & ) const - { - } -}; - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - try{ - boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); - boost::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::sregex_iterator begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - //boost::regex_grep(&dummy_grep_proc, text, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_grep(&dummy_grep_proc, text, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -} - diff --git a/performance/time_dynamic_xpressive.cpp b/performance/time_dynamic_xpressive.cpp deleted file mode 100644 index 6fc7137c..00000000 --- a/performance/time_dynamic_xpressive.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * Copyright (c) 2004 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" - -#ifdef BOOST_HAS_XPRESSIVE -#include -#include -#include -#include - -namespace dxpr -{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - try{ - boost::xpressive::regex_constants::syntax_option_type flags = boost::xpressive::regex_constants::optimize; - if(icase) - flags = flags | boost::xpressive::regex_constants::icase; - boost::xpressive::sregex e(boost::xpressive::sregex::compile(re, flags)); - boost::xpressive::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - assert(boost::xpressive::regex_match( text, what, e )); - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::xpressive::regex_match( text, what, e ); - } - result = tim.elapsed(); - iter *= 2; - } while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::xpressive::regex_match( text, what, e ); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -struct noop -{ - void operator()( boost::xpressive::smatch const & ) const - { - } -}; - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - try{ - boost::xpressive::regex_constants::syntax_option_type flags = boost::xpressive::regex_constants::optimize; - if(icase) - flags = flags | boost::xpressive::regex_constants::icase; - boost::xpressive::sregex e(boost::xpressive::sregex::compile(re, flags)); - boost::xpressive::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::xpressive::sregex_iterator begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::xpressive::sregex_iterator begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -} - -#else - -namespace dxpr{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -} -#endif - - diff --git a/performance/time_greta.cpp b/performance/time_greta.cpp deleted file mode 100644 index 22b1d9f6..00000000 --- a/performance/time_greta.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" -#if defined(BOOST_HAS_GRETA) -#include -#include -#include "regexpr2.h" - -namespace g{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - regex::rpattern e(re, (icase ? regex::MULTILINE | regex::NORMALIZE | regex::NOCASE : regex::MULTILINE | regex::NORMALIZE)); - regex::match_results what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - assert(e.match(text, what)); - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text, what); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text, what); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - regex::rpattern e(re, (icase ? regex::MULTILINE | regex::NORMALIZE | regex::NOCASE : regex::MULTILINE | regex::NORMALIZE)); - regex::match_results what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text.begin(), text.end(), what); - while(what.backref(0).matched) - { - e.match(what.backref(0).end(), text.end(), what); - } - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result > 10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text.begin(), text.end(), what); - while(what.backref(0).matched) - { - e.match(what.backref(0).end(), text.end(), what); - } - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -} - -#else - -namespace g { - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -} - -#endif - - diff --git a/performance/time_localised_boost.cpp b/performance/time_localised_boost.cpp deleted file mode 100644 index d2a27bf4..00000000 --- a/performance/time_localised_boost.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" -#include -#include - -namespace bl{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - boost::basic_regex > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); - boost::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_match(text, what, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_match(text, what, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -bool dummy_grep_proc(const boost::smatch&) -{ return true; } - -struct noop -{ - void operator()( boost::smatch const & ) const - { - } -}; - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - boost::basic_regex > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl)); - boost::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_iterator< - std::string::const_iterator, - char, - boost::cpp_regex_traits > begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - //boost::regex_grep(&dummy_grep_proc, text, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - boost::regex_grep(&dummy_grep_proc, text, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -} - diff --git a/performance/time_pcre.cpp b/performance/time_pcre.cpp deleted file mode 100644 index 47d6ce8c..00000000 --- a/performance/time_pcre.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include -#include -#include "regex_comparison.hpp" -#ifdef BOOST_HAS_PCRE -#include "pcre.h" -#include - -namespace pcr{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - pcre *ppcre; - const char *error; - int erroffset; - - int what[50]; - - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - - if(0 == (ppcre = pcre_compile(re.c_str(), (icase ? PCRE_CASELESS | PCRE_ANCHORED | PCRE_DOTALL | PCRE_MULTILINE : PCRE_ANCHORED | PCRE_DOTALL | PCRE_MULTILINE), - &error, &erroffset, NULL))) - { - free(ppcre); - return -1; - } - - pcre_extra *pe; - pe = pcre_study(ppcre, 0, &error); - if(error) - { - free(ppcre); - free(pe); - return -1; - } - - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - erroffset = pcre_exec(ppcre, pe, text.c_str(), text.size(), 0, 0, what, sizeof(what)/sizeof(int)); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - erroffset = pcre_exec(ppcre, pe, text.c_str(), text.size(), 0, 0, what, sizeof(what)/sizeof(int)); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - free(ppcre); - free(pe); - return result / iter; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - pcre *ppcre; - const char *error; - int erroffset; - - int what[50]; - - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - int exec_result; - int matches; - - if(0 == (ppcre = pcre_compile(re.c_str(), (icase ? PCRE_CASELESS | PCRE_DOTALL | PCRE_MULTILINE : PCRE_DOTALL | PCRE_MULTILINE), &error, &erroffset, NULL))) - { - free(ppcre); - return -1; - } - - pcre_extra *pe; - pe = pcre_study(ppcre, 0, &error); - if(error) - { - free(ppcre); - free(pe); - return -1; - } - - do - { - int startoff; - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - matches = 0; - startoff = 0; - exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); - while(exec_result >= 0) - { - ++matches; - startoff = what[1]; - exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); - } - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - result = DBL_MAX; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - int startoff; - matches = 0; - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - matches = 0; - startoff = 0; - exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); - while(exec_result >= 0) - { - ++matches; - startoff = what[1]; - exec_result = pcre_exec(ppcre, pe, text.c_str(), text.size(), startoff, 0, what, sizeof(what)/sizeof(int)); - } - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -} -#else - -namespace pcr{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -} - -#endif diff --git a/performance/time_posix.cpp b/performance/time_posix.cpp deleted file mode 100644 index f5192187..00000000 --- a/performance/time_posix.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include -#include -#include "regex_comparison.hpp" -#ifdef BOOST_HAS_POSIX -#include -#include "regex.h" - -namespace posix{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - regex_t e; - regmatch_t what[20]; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - if(0 != ::regcomp(&e, re.c_str(), (icase ? REG_ICASE | REG_EXTENDED : REG_EXTENDED))) - return -1; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - regexec(&e, text.c_str(), e.re_nsub, what, 0); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - regexec(&e, text.c_str(), e.re_nsub, what, 0); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - regfree(&e); - return result / iter; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - regex_t e; - regmatch_t what[20]; - memset(what, 0, sizeof(what)); - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - int exec_result; - int matches; - if(0 != regcomp(&e, re.c_str(), (icase ? REG_ICASE | REG_EXTENDED : REG_EXTENDED))) - return -1; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - what[0].rm_so = 0; - what[0].rm_eo = text.size(); - matches = 0; - exec_result = regexec(&e, text.c_str(), 20, what, REG_STARTEND); - while(exec_result == 0) - { - ++matches; - what[0].rm_so = what[0].rm_eo; - what[0].rm_eo = text.size(); - exec_result = regexec(&e, text.c_str(), 20, what, REG_STARTEND); - } - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - result = DBL_MAX; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - what[0].rm_so = 0; - what[0].rm_eo = text.size(); - matches = 0; - exec_result = regexec(&e, text.c_str(), 20, what, REG_STARTEND); - while(exec_result == 0) - { - ++matches; - what[0].rm_so = what[0].rm_eo; - what[0].rm_eo = text.size(); - exec_result = regexec(&e, text.c_str(), 20, what, REG_STARTEND); - } - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -} -#else - -namespace posix{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -} -#endif diff --git a/performance/time_safe_greta.cpp b/performance/time_safe_greta.cpp deleted file mode 100644 index c68cfb34..00000000 --- a/performance/time_safe_greta.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" -#if defined(BOOST_HAS_GRETA) - -#include -#include -#include "regexpr2.h" - -namespace gs{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - regex::rpattern e(re, (icase ? regex::MULTILINE | regex::NORMALIZE | regex::NOCASE : regex::MULTILINE | regex::NORMALIZE), regex::MODE_SAFE); - regex::match_results what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - assert(e.match(text, what)); - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text, what); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text, what); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - regex::rpattern e(re, (icase ? regex::MULTILINE | regex::NORMALIZE | regex::NOCASE : regex::MULTILINE | regex::NORMALIZE), regex::MODE_SAFE); - regex::match_results what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - bool r; - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text.begin(), text.end(), what); - while(what.backref(0).matched) - { - e.match(what.backref(0).end(), text.end(), what); - } - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result > 10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - e.match(text.begin(), text.end(), what); - while(what.backref(0).matched) - { - e.match(what.backref(0).end(), text.end(), what); - } - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; -} - -} - -#else - -namespace gs{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - return -1; -} - -} - -#endif - - diff --git a/performance/time_std.cpp b/performance/time_std.cpp deleted file mode 100644 index 9284add1..00000000 --- a/performance/time_std.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * Copyright (c) 2002 - * John Maddock - * - * 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) - * - */ - -#include "regex_comparison.hpp" -#ifndef BOOST_NO_CXX11_HDR_REGEX -#include -#include -#include - -namespace stdr{ - -double time_match(const std::string& re, const std::string& text, bool icase) -{ - try{ - std::regex e(re, (icase ? std::regex::ECMAScript | std::regex::icase : std::regex::ECMAScript)); - std::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - std::regex_match(text, what, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - std::regex_match(text, what, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -bool dummy_grep_proc(const std::smatch&) -{ return true; } - -struct noop -{ - void operator()( std::smatch const & ) const - { - } -}; - -double time_find_all(const std::string& re, const std::string& text, bool icase) -{ - try{ - std::regex e(re, (icase ? std::regex::ECMAScript | std::regex::icase : std::regex::ECMAScript)); - std::smatch what; - boost::timer tim; - int iter = 1; - int counter, repeats; - double result = 0; - double run; - do - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - std::sregex_iterator begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - //std::regex_grep(&dummy_grep_proc, text, e); - } - result = tim.elapsed(); - iter *= 2; - }while(result < 0.5); - iter /= 2; - - if(result >10) - return result / iter; - - // repeat test and report least value for consistency: - for(repeats = 0; repeats < REPEAT_COUNT; ++repeats) - { - tim.restart(); - for(counter = 0; counter < iter; ++counter) - { - std::sregex_iterator begin( text.begin(), text.end(), e ), end; - std::for_each( begin, end, noop() ); - //std::regex_grep(&dummy_grep_proc, text, e); - } - run = tim.elapsed(); - result = (std::min)(run, result); - } - return result / iter; - } - catch(const std::exception& e) - { - std::cout << "Exception: " << e.what() << std::endl; - return -1; - } -} - -} - -#endif diff --git a/performance/xpressive.cpp b/performance/xpressive.cpp new file mode 100644 index 00000000..22b57cfc --- /dev/null +++ b/performance/xpressive.cpp @@ -0,0 +1,74 @@ +/////////////////////////////////////////////////////////////// +// Copyright 2015 John Maddock. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_ +// + +#include + +#include "performance.hpp" +#include + +using namespace boost::xpressive; + +struct xpressive_regex : public abstract_regex +{ +private: + cregex e; + cmatch what; +public: + virtual bool set_expression(const char* pe, bool isperl) + { + if(!isperl) + return false; + try + { + e = cregex::compile(pe, regex_constants::ECMAScript); + } + catch(const std::exception&) + { + return false; + } + return true; + } + virtual bool match_test(const char* text); + virtual unsigned find_all(const char* text); + virtual std::string name(); + + struct initializer + { + initializer() + { + xpressive_regex::register_instance(boost::shared_ptr(new xpressive_regex)); + } + void do_nothing()const {} + }; + static const initializer init; +}; + +const xpressive_regex::initializer xpressive_regex::init; + + +bool xpressive_regex::match_test(const char * text) +{ + return regex_match(text, what, e); +} + +unsigned xpressive_regex::find_all(const char * text) +{ + cregex_token_iterator i(text, text + std::strlen(text), e), j; + unsigned count = 0; + while(i != j) + { + ++i; + ++count; + } + return count; +} + +std::string xpressive_regex::name() +{ + init.do_nothing(); + return "boost::xpressive::cregex"; +} +