early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,70 @@
# 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.
# bring in the rules for testing
import testing ;
import modules ;
import path ;
import pch ;
using quickbook ;
using auto-index ;
path-constant images_location : html ;
path-constant here : . ;
lib pcre2-8 ;
lib re2 ;
exe has_pcre2 : config/pcre.cpp pcre2-8 : <include>third_party <dll-path>third_party <library-path>third_party release ;
explicit has_pcre2 ;
exe has_posix : config/posix.cpp : release ;
explicit has_posix ;
exe has_re2 : config/re2.cpp : release <source>re2 <include>third_party <dll-path>third_party <library-path>third_party ;
explicit has_re2 ;
run [ glob *.cpp ] /boost/regex//boost_regex /boost/system /boost/chrono /boost/filesystem
: : :
release
[ check-target-builds has_pcre2 : <define>TEST_PCRE2 <source>pcre2-8 ]
[ check-target-builds has_posix : <define>TEST_POSIX ]
[ check-target-builds has_re2 : <define>TEST_RE2 <source>re2 <include>third_party <dll-path>third_party <library-path>third_party ]
<include>third_party
<dll-path>third_party
<library-path>third_party
: performance ;
xml report : doc/report.qbk : <dependency>performance ;
boostbook standalone
:
report
:
# Path for links to Boost:
<xsl:param>boost.root=../../../..
# Some general style settings:
<xsl:param>table.footnote.number.format=1
<xsl:param>footnote.number.format=1
<xsl:param>html.stylesheet=../../../../doc/src/boostbook.css
# HTML options first:
# Use graphics not text for navigation:
<xsl:param>navig.graphics=1
# How far down we chunk nested sections, basically all of them:
<xsl:param>chunk.section.depth=0
# Don't put the first section on the same page as the TOC:
<xsl:param>chunk.first.sections=0
# How far down sections get TOC's
<xsl:param>toc.section.depth=2
# Max depth in each TOC:
<xsl:param>toc.max.depth=4
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=10
;

View File

@@ -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 <boost/regex.hpp>
#include <boost/version.hpp>
#include <boost/lexical_cast.hpp>
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<abstract_regex>(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<const char*> 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();
}

View File

@@ -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 <pcre2.h>
int main()
{
pcre2_match_data* pdata = pcre2_match_data_create(30, NULL);
pcre2_match_data_free(pdata);
return 0;
}

View File

@@ -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 <regex.h>
int main()
{
regex_t pe;
int r = regcomp(&pe, "foo", REG_EXTENDED);
regfree(&pe);
return r;
}

View File

@@ -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 <re2.h>
int main()
{
return re2::RE2::FullMatch("a", "a") ? 0 : 1;
}

View File

@@ -0,0 +1,212 @@
[/tables:]
[template table_Testing_Perl_searches_platform_linux_compiler_GNU_C_version_6_3_0_[]
[table:table_Testing_Perl_searches_platform_linux_compiler_GNU_C_version_6_3_0_ Testing Perl searches (platform = linux, compiler = GNU C++ version 6.3.0)
[[Expression[br]Text][boost 1.65][std::regex][boost::xpressive::cregex][PCRE-10.21]]
[[[^(?i)<a\u005B\^>\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 1.63[br](28838ns)]][[role grey -]][[role blue 1.67[br](29436ns)]][[role green 1.00[br](17678ns)]]]
[[[^(?i)<font\u005B\^>\u005D+face\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>.\*?<\/font>][br]In file: ../../../libs/libraries.htm][[role blue 2.78[br](19366ns)]][[role grey -]][[role blue 1.50[br](10471ns)]][[role green 1.00[br](6963ns)]]]
[[[^(?i)<h\u005B12345678\u005D\u005B\^>\u005D\*>.\*?<\/h\u005B12345678\u005D>][br]In file: ../../../libs/libraries.htm][[role blue 1.95[br](17081ns)]][[role grey -]][[role blue 2.18[br](19086ns)]][[role green 1.00[br](8745ns)]]]
[[[^(?i)<img\u005B\^>\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 2.61[br](18132ns)]][[role grey -]][[role blue 1.61[br](11211ns)]][[role green 1.00[br](6952ns)]]]
[[[^(?i)<p>.\*?<\/p>][br]In file: ../../../libs/libraries.htm][[role blue 1.69[br](17517ns)]][[role grey -]][[role blue 1.51[br](15645ns)]][[role green 1.00[br](10345ns)]]]
[[[^(\\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](1500580ns)]][[role grey -]][[role grey -]][[role blue 2.84[br](4260530ns)]]]
[[[^(\^\u005B \\t\u005D\*\#(?:(?>\u005B\^\\\\\\n\u005D+)|\\\\(?>\\s\*\\n|.))\*)|][br]In file: boost/multiprecision/number.hpp][[role blue 1.64[br](14163004ns)]][[role grey -]][[role green 1.00[br](8632111ns)]][[role green 1.03[br](8907897ns)]]]
[[[^(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 blue 1.72[br](13046296ns)]][[role blue 3.61[br](27370747ns)]][[role green 1.00[br](7585304ns)]][[role blue 1.98[br](14992880ns)]]]
[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](5021ns)]][[role red 36.75[br](184532ns)]][[role blue 1.40[br](7046ns)]][[role green 1.19[br](5966ns)]]]
[[[^\\w+\\s\*(\\(\u005B\^()\u005D++(?:(?1)\u005B\^()\u005D++)\*+\u005B\^)\u005D\*\\))][br]In file: boost/multiprecision/number.hpp][[role green 1.00[br](1551419ns)]][[role grey -]][[role grey -]][[role blue 1.58[br](2444759ns)]]]
[[[^\\{\u005B\^{}\u005D++((?0)\u005B\^{}\u005D++)\*+\u005B\^}\u005D\*+\\}][br]In file: boost/multiprecision/number.hpp][[role blue 1.31[br](200846ns)]][[role grey -]][[role grey -]][[role green 1.00[br](153117ns)]]]
[[[^\^\u005B \u005D\*\#\u005B \u005D\*include\u005B \u005D+("\u005B\^"\u005D+"|<\u005B\^>\u005D+>)][br]In file: boost/multiprecision/number.hpp][[role blue 1.46[br](234901ns)]][[role red 11.35[br](1821532ns)]][[role green 1.00[br](160446ns)]][[role blue 1.35[br](215802ns)]]]
[[[^\^\u005B \u005D\*\#\u005B \u005D\*include\u005B \u005D+("boost\/\u005B\^"\u005D+"|<boost\/\u005B\^>\u005D+>)][br]In file: boost/multiprecision/number.hpp][[role blue 1.41[br](234377ns)]][[role red 11.47[br](1903901ns)]][[role green 1.00[br](165921ns)]][[role blue 1.31[br](217806ns)]]]
]
]
[template table_Testing_leftmost_longest_searches_platform_linux_compiler_GNU_C_version_6_3_0_[]
[table:table_Testing_leftmost_longest_searches_platform_linux_compiler_GNU_C_version_6_3_0_ Testing leftmost-longest searches (platform = linux, compiler = GNU C++ version 6.3.0)
[[Expression[br]Text][boost 1.65][std::regex][POSIX]]
[[[^<a\u005B\^>\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](107026ns)]][[role blue 1.44[br](154551ns)]][[role blue 1.64[br](175184ns)]]]
[[[^<img\u005B\^>\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](15420ns)]][[role red 6.89[br](106275ns)]][[role blue 1.59[br](24567ns)]]]
[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role green 1.03[br](5399ns)]][[role red 36.27[br](190577ns)]][[role green 1.00[br](5254ns)]]]
]
]
[template table_Testing_simple_Perl_matches_platform_linux_compiler_GNU_C_version_6_3_0_[]
[table:table_Testing_simple_Perl_matches_platform_linux_compiler_GNU_C_version_6_3_0_ Testing simple Perl matches (platform = linux, compiler = GNU C++ version 6.3.0)
[[Expression[br]Text][boost 1.65][std::regex][boost::xpressive::cregex][PCRE-10.21]]
[[[^(\u005B\u005B:digit:\u005D\u005D{4}\u005B- \u005D){3}\u005B\u005B:digit:\u005D\u005D{3,4}][br][^1234-5678-1234-456]][[role blue 2.65[br](506ns)]][[role blue 2.86[br](546ns)]][[role green 1.00[br](191ns)]][[role blue 1.37[br](262ns)]]]
[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role blue 2.52[br](353ns)]][[role red 20.99[br](2939ns)]][[role green 1.00[br](140ns)]][[role blue 3.50[br](490ns)]]]
[[[^\^(\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 1.98[br](681ns)]][[role grey -]][[role green 1.00[br](344ns)]][[role blue 1.32[br](454ns)]]]
[[[^\^(\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.06[br](695ns)]][[role grey -]][[role green 1.00[br](337ns)]][[role blue 1.34[br](451ns)]]]
[[[^\^(\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 1.93[br](821ns)]][[role grey -]][[role green 1.00[br](425ns)]][[role blue 1.24[br](526ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role blue 2.34[br](243ns)]][[role red 4.45[br](463ns)]][[role green 1.00[br](104ns)]][[role blue 1.62[br](168ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role blue 2.33[br](245ns)]][[role red 4.39[br](461ns)]][[role green 1.00[br](105ns)]][[role blue 1.60[br](168ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role blue 2.08[br](208ns)]][[role blue 3.31[br](331ns)]][[role green 1.00[br](100ns)]][[role blue 1.52[br](152ns)]]]
[[[^\^\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 2.28[br](237ns)]][[role blue 3.39[br](353ns)]][[role green 1.00[br](104ns)]][[role green 1.18[br](123ns)]]]
[[[^\^\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 2.12[br](216ns)]][[role blue 3.02[br](308ns)]][[role green 1.00[br](102ns)]][[role green 1.19[br](121ns)]]]
[[[^\^\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 2.12[br](257ns)]][[role blue 2.66[br](322ns)]][[role green 1.00[br](121ns)]][[role green 1.17[br](142ns)]]]
[[[^\^\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 2.00[br](230ns)]][[role blue 2.65[br](305ns)]][[role green 1.00[br](115ns)]][[role blue 1.22[br](140ns)]]]
[[[^\^\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 2.05[br](244ns)]][[role blue 2.81[br](334ns)]][[role green 1.00[br](119ns)]][[role blue 1.22[br](145ns)]]]
[[[^abc][br][^abc]][[role blue 1.65[br](135ns)]][[role blue 1.83[br](150ns)]][[role green 1.00[br](82ns)]][[role green 1.02[br](84ns)]]]
]
]
[template table_Testing_simple_leftmost_longest_matches_platform_linux_compiler_GNU_C_version_6_3_0_[]
[table:table_Testing_simple_leftmost_longest_matches_platform_linux_compiler_GNU_C_version_6_3_0_ Testing simple leftmost-longest matches (platform = linux, compiler = GNU C++ version 6.3.0)
[[Expression[br]Text][boost 1.65][std::regex][POSIX]]
[[[^(\u005B\u005B:digit:\u005D\u005D{4}\u005B- \u005D){3}\u005B\u005B:digit:\u005D\u005D{3,4}][br][^1234-5678-1234-456]][[role green 1.11[br](669ns)]][[role green 1.00[br](603ns)]][[role blue 3.70[br](2234ns)]]]
[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role green 1.00[br](781ns)]][[role red 4.52[br](3530ns)]][[role red 12.72[br](9933ns)]]]
[[[^\^(\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](937ns)]][[role blue 1.26[br](1184ns)]][[role blue 3.06[br](2864ns)]]]
[[[^\^(\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](892ns)]][[role blue 1.29[br](1150ns)]][[role blue 2.95[br](2628ns)]]]
[[[^\^(\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](1160ns)]][[role blue 1.31[br](1517ns)]][[role blue 3.29[br](3818ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role blue 1.58[br](485ns)]][[role blue 1.48[br](455ns)]][[role green 1.00[br](307ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role blue 1.50[br](466ns)]][[role blue 1.50[br](464ns)]][[role green 1.00[br](310ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role blue 3.10[br](666ns)]][[role blue 1.57[br](338ns)]][[role green 1.00[br](215ns)]]]
[[[^\^\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 2.18[br](373ns)]][[role blue 2.10[br](359ns)]][[role green 1.00[br](171ns)]]]
[[[^\^\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 2.27[br](363ns)]][[role blue 1.93[br](309ns)]][[role green 1.00[br](160ns)]]]
[[[^\^\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 2.90[br](473ns)]][[role blue 2.19[br](357ns)]][[role green 1.00[br](163ns)]]]
[[[^\^\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 2.56[br](386ns)]][[role blue 1.83[br](277ns)]][[role green 1.00[br](151ns)]]]
[[[^\^\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 2.46[br](381ns)]][[role blue 2.14[br](331ns)]][[role green 1.00[br](155ns)]]]
[[[^abc][br][^abc]][[role blue 2.35[br](324ns)]][[role green 1.11[br](153ns)]][[role green 1.00[br](138ns)]]]
]
]
[template table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_[]
[table:table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_ Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)
[[Expression[br]Text][boost 1.65][PCRE-10.10][RE2][std::regex][boost::xpressive::cregex]]
[[[^(?i)<a\u005B\^>\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 1.36[br](21565ns)]][[role green 1.00[br](15821ns)]][[role green 1.08[br](17111ns)]][[role grey -]][[role blue 2.89[br](45731ns)]]]
[[[^(?i)<font\u005B\^>\u005D+face\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>.\*?<\/font>][br]In file: ../../../libs/libraries.htm][[role blue 3.05[br](16442ns)]][[role blue 1.58[br](8492ns)]][[role green 1.00[br](5385ns)]][[role grey -]][[role blue 3.31[br](17804ns)]]]
[[[^(?i)<h\u005B12345678\u005D\u005B\^>\u005D\*>.\*?<\/h\u005B12345678\u005D>][br]In file: ../../../libs/libraries.htm][[role blue 2.11[br](15434ns)]][[role blue 1.31[br](9615ns)]][[role green 1.00[br](7315ns)]][[role grey -]][[role red 4.28[br](31331ns)]]]
[[[^(?i)<img\u005B\^>\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role blue 2.73[br](16457ns)]][[role blue 1.41[br](8503ns)]][[role green 1.00[br](6023ns)]][[role grey -]][[role blue 3.14[br](18913ns)]]]
[[[^(?i)<p>.\*?<\/p>][br]In file: ../../../libs/libraries.htm][[role blue 2.32[br](15717ns)]][[role blue 1.57[br](10652ns)]][[role green 1.00[br](6789ns)]][[role grey -]][[role blue 3.76[br](25542ns)]]]
[[[^(\\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](1125008ns)]][[role blue 2.90[br](3265708ns)]][[role grey -]][[role grey -]][[role grey -]]]
[[[^(\^\u005B \\t\u005D\*\#(?:(?>\u005B\^\\\\\\n\u005D+)|\\\\(?>\\s\*\\n|.))\*)|][br]In file: boost/multiprecision/number.hpp][[role blue 1.55[br](11035845ns)]][[role green 1.00[br](7123895ns)]][[role grey -]][[role grey -]][[role blue 1.46[br](10415180ns)]]]
[[[^(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 26.17[br](8436744ns)]][[role red 32.97[br](10629852ns)]][[role green 1.00[br](322399ns)]][[role red 811.84[br](261737971ns)]][[role red 23.34[br](7526351ns)]]]
[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role blue 1.58[br](10246ns)]][[role green 1.00[br](6487ns)]][[role blue 2.48[br](16109ns)]][[role red 5.39[br](34994ns)]][[role green 1.09[br](7046ns)]]]
[[[^\\w+\\s\*(\\(\u005B\^()\u005D++(?:(?1)\u005B\^()\u005D++)\*+\u005B\^)\u005D\*\\))][br]In file: boost/multiprecision/number.hpp][[role green 1.00[br](1152646ns)]][[role blue 1.70[br](1962067ns)]][[role grey -]][[role grey -]][[role grey -]]]
[[[^\\{\u005B\^{}\u005D++((?0)\u005B\^{}\u005D++)\*+\u005B\^}\u005D\*+\\}][br]In file: boost/multiprecision/number.hpp][[role blue 1.62[br](255439ns)]][[role green 1.00[br](158034ns)]][[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.48[br](268270ns)]][[role green 1.08[br](195553ns)]][[role blue 1.78[br](323879ns)]][[role red 7.75[br](1406976ns)]][[role green 1.00[br](181554ns)]]]
[[[^\^\u005B \u005D\*\#\u005B \u005D\*include\u005B \u005D+("boost\/\u005B\^"\u005D+"|<boost\/\u005B\^>\u005D+>)][br]In file: boost/multiprecision/number.hpp][[role blue 1.48[br](268560ns)]][[role green 1.08[br](195915ns)]][[role blue 1.76[br](319886ns)]][[role red 7.72[br](1398962ns)]][[role green 1.00[br](181328ns)]]]
]
]
[template table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_[]
[table:table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_ Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)
[[Expression[br]Text][boost 1.65][std::regex]]
[[[^<a\u005B\^>\u005D+href\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](80801ns)]][[role red 6.82[br](551022ns)]]]
[[[^<img\u005B\^>\u005D+src\=("\u005B\^"\u005D\*"|\u005B\^\u005B:space:\u005D\u005D+)\u005B\^>\u005D\*>][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](19868ns)]][[role red 4.23[br](84068ns)]]]
[[[^Beman|John|Dave][br]In file: ../../../libs/libraries.htm][[role green 1.00[br](10508ns)]][[role blue 3.37[br](35378ns)]]]
]
]
[template table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_[]
[table:table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_ Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)
[[Expression[br]Text][boost 1.65][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 1.90[br](328ns)]][[role green 1.18[br](205ns)]][[role green 1.00[br](173ns)]][[role red 27.81[br](4811ns)]][[role blue 1.32[br](228ns)]]]
[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role blue 1.45[br](251ns)]][[role blue 1.73[br](300ns)]][[role blue 2.14[br](371ns)]][[role red 24.75[br](4281ns)]][[role green 1.00[br](173ns)]]]
[[[^\^(\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.53[br](403ns)]][[role blue 2.13[br](338ns)]][[role green 1.00[br](159ns)]][[role red 34.16[br](5432ns)]][[role blue 1.86[br](295ns)]]]
[[[^\^(\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.75[br](402ns)]][[role blue 2.34[br](342ns)]][[role green 1.00[br](146ns)]][[role red 40.78[br](5954ns)]][[role blue 2.01[br](294ns)]]]
[[[^\^(\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.54[br](469ns)]][[role blue 2.16[br](399ns)]][[role green 1.00[br](185ns)]][[role red 44.27[br](8190ns)]][[role blue 2.04[br](377ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role blue 1.53[br](171ns)]][[role green 1.14[br](128ns)]][[role green 1.11[br](124ns)]][[role red 21.63[br](2422ns)]][[role green 1.00[br](112ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role blue 1.50[br](167ns)]][[role green 1.15[br](128ns)]][[role green 1.13[br](125ns)]][[role red 21.92[br](2433ns)]][[role green 1.00[br](111ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role blue 1.40[br](143ns)]][[role green 1.15[br](117ns)]][[role green 1.03[br](105ns)]][[role red 35.65[br](3636ns)]][[role green 1.00[br](102ns)]]]
[[[^\^\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.47[br](157ns)]][[role green 1.00[br](107ns)]][[role blue 1.27[br](136ns)]][[role red 16.75[br](1792ns)]][[role green 1.03[br](110ns)]]]
[[[^\^\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.39[br](145ns)]][[role green 1.00[br](104ns)]][[role green 1.13[br](117ns)]][[role red 16.90[br](1758ns)]][[role green 1.07[br](111ns)]]]
[[[^\^\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.44[br](164ns)]][[role green 1.00[br](114ns)]][[role green 1.10[br](125ns)]][[role red 15.61[br](1779ns)]][[role green 1.06[br](121ns)]]]
[[[^\^\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.36[br](152ns)]][[role green 1.00[br](112ns)]][[role green 1.04[br](117ns)]][[role red 15.86[br](1776ns)]][[role green 1.05[br](118ns)]]]
[[[^\^\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.40[br](158ns)]][[role green 1.00[br](113ns)]][[role green 1.10[br](124ns)]][[role red 15.86[br](1792ns)]][[role green 1.07[br](121ns)]]]
[[[^abc][br][^abc]][[role blue 2.01[br](141ns)]][[role green 1.00[br](70ns)]][[role green 1.17[br](82ns)]][[role red 8.24[br](577ns)]][[role green 1.19[br](83ns)]]]
]
]
[template table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_[]
[table:table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_ Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)
[[Expression[br]Text][boost 1.65][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](554ns)]][[role red 11.06[br](6127ns)]]]
[[[^\^(\u005B0-9\u005D+)(\\-| |\$)(.\*)\$][br][^100- this is a line of ftp response which contains a message string]][[role green 1.00[br](679ns)]][[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](1444ns)]][[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](1397ns)]][[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](1588ns)]][[role grey -]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^+3.14159]][[role green 1.00[br](466ns)]][[role red 11.18[br](5208ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^-3.14159]][[role green 1.00[br](519ns)]][[role red 9.79[br](5083ns)]]]
[[[^\^\u005B-+\u005D?\u005B\u005B:digit:\u005D\u005D\*\\.?\u005B\u005B:digit:\u005D\u005D\*\$][br][^123]][[role green 1.00[br](619ns)]][[role red 7.64[br](4730ns)]]]
[[[^\^\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](449ns)]][[role red 5.23[br](2347ns)]]]
[[[^\^\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](362ns)]][[role red 6.48[br](2344ns)]]]
[[[^\^\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](1090ns)]][[role blue 2.48[br](2699ns)]]]
[[[^\^\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](348ns)]][[role red 6.57[br](2288ns)]]]
[[[^\^\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](358ns)]][[role red 6.41[br](2296ns)]]]
[[[^abc][br][^abc]][[role green 1.00[br](375ns)]][[role blue 2.30[br](864ns)]]]
]
]
[/sections:]
[template section_id1675827111[]
[section:section_id1675827111 Testing Perl searches (platform = linux, compiler = GNU C++ version 6.3.0)]
[table_Testing_Perl_searches_platform_linux_compiler_GNU_C_version_6_3_0_]
[endsect]
]
[template section_id4148872883[]
[section:section_id4148872883 Testing leftmost-longest searches (platform = linux, compiler = GNU C++ version 6.3.0)]
[table_Testing_leftmost_longest_searches_platform_linux_compiler_GNU_C_version_6_3_0_]
[endsect]
]
[template section_id3261825021[]
[section:section_id3261825021 Testing simple Perl matches (platform = linux, compiler = GNU C++ version 6.3.0)]
[table_Testing_simple_Perl_matches_platform_linux_compiler_GNU_C_version_6_3_0_]
[endsect]
]
[template section_id1378460593[]
[section:section_id1378460593 Testing simple leftmost-longest matches (platform = linux, compiler = GNU C++ version 6.3.0)]
[table_Testing_simple_leftmost_longest_matches_platform_linux_compiler_GNU_C_version_6_3_0_]
[endsect]
]
[template section_id3752650613[]
[section:section_id3752650613 Testing Perl searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)]
[table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[endsect]
]
[template section_id3258595385[]
[section:section_id3258595385 Testing leftmost-longest searches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)]
[table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[endsect]
]
[template section_id4128344975[]
[section:section_id4128344975 Testing simple Perl matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)]
[table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[endsect]
]
[template section_id3141719723[]
[section:section_id3141719723 Testing simple leftmost-longest matches (platform = Windows x64, compiler = Microsoft Visual C++ version 14.1)]
[table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[endsect]
]
[template performance_all_sections[]
[section_id1378460593]
[section_id1675827111]
[section_id3141719723]
[section_id3258595385]
[section_id3261825021]
[section_id3752650613]
[section_id4128344975]
[section_id4148872883]
]
[template performance_all_tables[]
[table_Testing_Perl_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[table_Testing_Perl_searches_platform_linux_compiler_GNU_C_version_6_3_0_]
[table_Testing_leftmost_longest_searches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[table_Testing_leftmost_longest_searches_platform_linux_compiler_GNU_C_version_6_3_0_]
[table_Testing_simple_Perl_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[table_Testing_simple_Perl_matches_platform_linux_compiler_GNU_C_version_6_3_0_]
[table_Testing_simple_leftmost_longest_matches_platform_Windows_x64_compiler_Microsoft_Visual_C_version_14_1_]
[table_Testing_simple_leftmost_longest_matches_platform_linux_compiler_GNU_C_version_6_3_0_]
]

View File

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

View File

@@ -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 <pcre2.h>
#include <boost/version.hpp>
#include <boost/lexical_cast.hpp>
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<abstract_regex>(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<std::string>(PCRE2_MAJOR) + "." + boost::lexical_cast<std::string>(PCRE2_MINOR);
}
#endif

View File

@@ -0,0 +1,259 @@
///////////////////////////////////////////////////////////////
// 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 <list>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <boost/chrono.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
void load_file(std::string& text, const char* file)
{
std::deque<char> 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<char> it(is);
std::copy(it, std::istreambuf_iterator<char>(), std::back_inserter(text));
}
typedef std::list<boost::shared_ptr<abstract_regex> > list_type;
list_type& engines()
{
static list_type l;
return l;
}
void abstract_regex::register_instance(boost::shared_ptr<abstract_regex> item)
{
engines().push_back(item);
}
template <class Clock>
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 <class Func>
double exec_timed_test(Func f)
{
double t = 0;
unsigned repeats = 1;
do {
stopwatch<boost::chrono::high_resolution_clock> w;
for(unsigned count = 0; count < repeats; ++count)
{
last_value_returned = f();
sum += last_value_returned;
}
t = boost::chrono::duration_cast<boost::chrono::duration<double>>(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 << " occurrences.\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/[^\"]+\"|<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)<p>.*?</p>", file_contents.c_str(), true, "../../../libs/libraries.htm");
test_search("<a[^>]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), false, "../../../libs/libraries.htm");
test_search("(?i)<a[^>]+href=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), true, "../../../libs/libraries.htm");
test_search("(?i)<h[12345678][^>]*>.*?</h[12345678]>", file_contents.c_str(), true, "../../../libs/libraries.htm");
test_search("<img[^>]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), false, "../../../libs/libraries.htm");
test_search("(?i)<img[^>]+src=(\"[^\"]*\"|[^[:space:]]+)[^>]*>", file_contents.c_str(), true, "../../../libs/libraries.htm");
test_search("(?i)<font[^>]+face=(\"[^\"]*\"|[^[:space:]]+)[^>]*>.*?</font>", 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;
}

View File

@@ -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 <string>
#include <boost/shared_ptr.hpp>
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<abstract_regex> 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

View File

@@ -0,0 +1,97 @@
///////////////////////////////////////////////////////////////
// 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 <boost/lexical_cast.hpp>
#include <regex.h>
struct posix_regex : public abstract_regex
{
private:
regex_t pe, pe2;
bool init;
public:
posix_regex() : 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<abstract_regex>(new posix_regex));
}
void do_nothing()const {}
};
static const initializer init2;
};
const posix_regex::initializer posix_regex::init2;
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_eo;
if(m[0].rm_eo - m[0].rm_so)
flags = *(text - 1) == '\n' ? 0 : REG_NOTBOL;
else
flags = 0;
}
return 0;
}
std::string posix_regex::name()
{
init2.do_nothing();
return "POSIX";
}
#endif

View File

@@ -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 <boost/scoped_ptr.hpp>
#include <re2.h>
using namespace re2;
struct re2_regex : public abstract_regex
{
private:
boost::scoped_ptr<RE2> 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<abstract_regex>(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

View File

@@ -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 <boost/config.hpp>
#ifndef BOOST_NO_CXX11_HDR_REGEX
#include "performance.hpp"
#include <regex>
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<abstract_regex>(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<const char*> 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

View File

@@ -0,0 +1,420 @@
// 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 <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/container_hash/hash.hpp>
#include <vector>
#include <set>
#include <iostream>
#include <sstream>
#include <iomanip>
std::vector<std::vector<double> > 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;
}
inline std::string sanitize_short_string(const std::string& s)
{
unsigned id = boost::hash<std::string>()(s);
return sanitize_string("id" + boost::lexical_cast<std::string>(id));
}
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<char>(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<std::vector<std::string> >& table, std::string::const_iterator begin, std::string::const_iterator end)
{
static const boost::regex item_e(
"\\["
"([^\\[\\]]*(?0)?)*"
"\\]"
);
boost::regex_token_iterator<std::string::const_iterator> i(begin, end, item_e), j;
while(i != j)
{
// Add a row:
table.push_back(std::vector<std::string>());
boost::regex_token_iterator<std::string::const_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<std::vector<std::string> >& table)
{
std::string result;
for(std::vector<std::vector<std::string> >::const_iterator i = table.begin(), j = table.end(); i != j; ++i)
{
result += "[";
for(std::vector<std::string>::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<std::string::const_iterator> i(content.begin() + pos + 12 + list_name.size(), content.end(), item_e), j;
std::set<std::string> 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<std::string>::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<boost::uintmax_t>(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<std::vector<std::string> > 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<std::string>());
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<boost::uintmax_t>::max)();
std::vector<boost::intmax_t> 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<double>(values[i - 1]) / best, 2);
s += "[br](";
s += boost::lexical_cast<std::string>(values[i - 1]) + "ns)]";
}
}
//
// Convert back to a string and insert into content:
std::sort(table_data.begin() + 1, table_data.end(), [](std::vector<std::string> const& a, std::vector<std::string> 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<std::string>(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_short_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<boost::uintmax_t>(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<std::string>(BOOST_VERSION / 100000) + "." + boost::lexical_cast<std::string>((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
}

View File

@@ -0,0 +1,3 @@
Place third party headers and libraries in this directory to have them built as part of the performance test application.
Or install in your compiler's search paths if you prefer.

View File

@@ -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 <boost/config.hpp>
#include "performance.hpp"
#include <boost/xpressive/xpressive.hpp>
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<abstract_regex>(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";
}