Skip to content

Add re2 and pcre jit test and fix posix regex bugs #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions doc/gcc44-performance.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions doc/html/boost_regex/background_information/performance.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<a href="../../../gcc-performance.html" target="_top">Gcc 3.2 (cygwin) (non-recursive
Boost.Regex implementation)</a>.
</li>
<li class="listitem">
<a href="../../../gcc44-performance.html" target="_top">Gcc 4.4 (CentOS 6) (non-recursive
Boost.Regex implementation)</a>.
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
Expand Down
28 changes: 25 additions & 3 deletions performance/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt.

SOURCES = command_line main time_boost time_greta time_localised_boost time_pcre time_dynamic_xpressive time_posix time_safe_greta ;
SOURCES = command_line main time_boost time_greta time_localised_boost time_pcre time_pcre_jit time_dynamic_xpressive time_posix time_safe_greta time_re2 ;

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 ] ;
local GRETA_PATH = [ modules.peek : GRETA_PATH ] ;
local USE_RE2 = [ modules.peek : USE_RE2 ] ;

if $(HS_REGEX_PATH)
{
Expand All @@ -20,31 +22,51 @@ else if $(USE_POSIX)
POSIX_OPTS = <define>BOOST_HAS_POSIX=1 ;
}

lib pcre : : <name>pcre ;
lib pcre : : <name>pcre <search>/usr/local/lib ;

if $(PCRE_PATH)
{
# currently pcre have more source files
PCRE_SOURCES = $(PCRE_PATH)/chartables.c $(PCRE_PATH)/get.c $(PCRE_PATH)/pcre.c $(PCRE_PATH)/study.c ;
PCRE_OPTS = <define>BOOST_HAS_PCRE=1 <include>$(PCRE_PATH) ;
}
else if $(USE_PCRE)
{
PCRE_OPTS = <define>BOOST_HAS_PCRE=1 ;
PCRE_OPTS = <define>BOOST_HAS_PCRE=1 <define>BOOST_HAS_PCRE_JIT=1 ;
PCRE_SOURCES = pcre ;
}

if $(GRETA_PATH)
{
GRETA_SOURCES = $(GRETA_PATH)/regexpr2.cpp $(GRETA_PATH)/syntax2.cpp ;
GRETA_OPTS = <define>BOOST_HAS_GRETA=1 <include>$(GRETA_PATH) ;
}

lib re2 : : <name>re2 ;

if $(USE_RE2)
{
RE2_OPTS = <define>BOOST_HAS_RE2=1 ;
RE2_SOURCES = re2 ;
}


exe regex_comparison :
$(SOURCES).cpp
$(HS_SOURCES)
$(PCRE_SOURCES)
$(GRETA_SOURCES)
$(RE2_SOURCES)
../build//boost_regex
../../test/build//boost_prg_exec_monitor/<link>static
:
<define>BOOST_REGEX_NO_LIB=1
<define>BOOST_REGEX_STATIC_LINK=1
<define>BOOST_HAS_XPRESSIVE=1
$(POSIX_OPTS)
$(PCRE_OPTS)
$(GRETA_OPTS)
$(RE2_OPTS)
;


Expand Down
82 changes: 78 additions & 4 deletions performance/command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ bool time_greta = false;
bool time_safe_greta = false;
bool time_posix = false;
bool time_pcre = false;
bool time_pcre_jit = false;
bool time_xpressive = false;
bool time_re2 = false;
bool time_std = false;

bool test_matches = false;
Expand All @@ -55,15 +57,19 @@ double boost_total = 0;
double locale_boost_total = 0;
double posix_total = 0;
double pcre_total = 0;
double pcre_jit_total = 0;
double xpressive_total = 0;
double re2_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 pcre_jit_test_count = 0;
unsigned xpressive_test_count = 0;
unsigned re2_test_count = 0;
unsigned std_test_count = 0;

int handle_argument(const std::string& what)
Expand All @@ -86,10 +92,18 @@ int handle_argument(const std::string& what)
else if(what == "-pcre")
time_pcre = true;
#endif
#ifdef BOOST_HAS_PCRE_JIT
else if(what == "-pcrejit")
time_pcre_jit = true;
#endif
#ifdef BOOST_HAS_XPRESSIVE
else if(what == "-xpressive" || what == "-dxpr")
time_xpressive = true;
#endif
#ifdef BOOST_HAS_RE2
else if(what == "-re2")
time_re2 = true;
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
else if(what == "-std")
time_std = true;
Expand All @@ -108,9 +122,15 @@ int handle_argument(const std::string& what)
#ifdef BOOST_HAS_PCRE
time_pcre = true;
#endif
#ifdef BOOST_HAS_PCRE_JIT
time_pcre_jit = true;
#endif
#ifdef BOOST_HAS_XPRESSIVE
time_xpressive = true;
#endif
#ifdef BOOST_HAS_RE2
time_re2 = true;
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
time_std = true;
#endif
Expand Down Expand Up @@ -174,9 +194,15 @@ int show_usage()
#ifdef BOOST_HAS_PCRE
" -pcre Apply tests to PCRE library\n"
#endif
#ifdef BOOST_HAS_PCRE_JIT
" -pcrejit Apply tests to PCRE library (int JIT mode)\n"
#endif
#ifdef BOOST_HAS_XPRESSIVE
" -dxpr Apply tests to dynamic xpressive library\n"
#endif
#ifdef BOOST_HAS_RE2
" -re2 Apply tests to google RE2 library\n"
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
" -std Apply tests to std::regex.\n"
#endif
Expand Down Expand Up @@ -283,10 +309,18 @@ void output_html_results(bool show_description, const std::string& tagname)
if(time_pcre == true)
os << "<td><strong>PCRE</strong></td>";
#endif
#ifdef BOOST_HAS_PCRE_JIT
if(time_pcre_jit == true)
os << "<td><strong>PCRE JIT</strong></td>";
#endif
#ifdef BOOST_HAS_XPRESSIVE
if(time_xpressive == true)
os << "<td><strong>Dynamic Xpressive</strong></td>";
#endif
#ifdef BOOST_HAS_RE2
if(time_re2 == true)
os << "<td><strong>RE2</strong></td>";
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
if(time_std == true)
os << "<td><strong>std::regex</strong></td>";
Expand Down Expand Up @@ -362,6 +396,17 @@ void output_html_results(bool show_description, const std::string& tagname)
}
}
#endif
#if defined(BOOST_HAS_PCRE_JIT)
if(time_pcre_jit == true)
{
print_result(os, first->pcre_jit_time, first->factor);
if(first->pcre_jit_time > 0)
{
pcre_jit_total += first->pcre_jit_time / first->factor;
++pcre_jit_test_count;
}
}
#endif
#if defined(BOOST_HAS_XPRESSIVE)
if(time_xpressive == true)
{
Expand All @@ -373,6 +418,17 @@ void output_html_results(bool show_description, const std::string& tagname)
}
}
#endif
#if defined(BOOST_HAS_RE2)
if(time_re2 == true)
{
print_result(os, first->re2_time, first->factor);
if(first->re2_time > 0)
{
re2_total += first->re2_time / first->factor;
++re2_test_count;
}
}
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
if(time_std == true)
{
Expand Down Expand Up @@ -450,12 +506,24 @@ std::string get_averages_table()
os << "<td><strong>PCRE</strong></td>";
}
#endif
#ifdef BOOST_HAS_PCRE_JIT
if(time_pcre_jit == true)
{
os << "<td><strong>PCRE JIT</strong></td>";
}
#endif
#ifdef BOOST_HAS_XPRESSIVE
if(time_xpressive == true)
{
os << "<td><strong>Dynamic Xpressive</strong></td>";
}
#endif
#ifdef BOOST_HAS_RE2
if(time_re2 == true)
{
os << "<td><strong>google RE2</strong></td>";
}
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
if(time_std == true)
{
Expand All @@ -473,25 +541,31 @@ std::string get_averages_table()
os << "<td>" << (greta_total / greta_test_count) << "</td>\n";
if(time_safe_greta == true)
os << "<td>" << (safe_greta_total / safe_greta_test_count) << "</td>\n";
#endif
#if defined(BOOST_HAS_POSIX)
if(time_boost == true)
os << "<td>" << (boost_total / boost_test_count) << "</td>\n";
#endif
if(time_boost == true)
os << "<td>" << (boost_total / boost_test_count) << "</td>\n";
if(time_localised_boost == true)
os << "<td>" << (locale_boost_total / locale_boost_test_count) << "</td>\n";
#if defined(BOOST_HAS_POSIX)
if(time_posix == true)
os << "<td>" << (posix_total / posix_test_count) << "</td>\n";
#endif
#if defined(BOOST_HAS_PCRE)
if(time_pcre == true)
os << "<td>" << (pcre_total / pcre_test_count) << "</td>\n";
#endif
#if defined(BOOST_HAS_PCRE_JIT)
if(time_pcre_jit == true)
os << "<td>" << (pcre_jit_total / pcre_jit_test_count) << "</td>\n";
#endif
#if defined(BOOST_HAS_XPRESSIVE)
if(time_xpressive == true)
os << "<td>" << (xpressive_total / xpressive_test_count) << "</td>\n";
#endif
#if defined(BOOST_HAS_RE2)
if(time_re2 == true)
os << "<td>" << (re2_total / re2_test_count) << "</td>\n";
#endif
#ifndef BOOST_NO_CXX11_HDR_REGEX
if(time_std == true)
os << "<td>" << (std_total / std_test_count) << "</td>\n";
Expand Down
2 changes: 1 addition & 1 deletion performance/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <H3>Comparison 4: HTML Document Search</H3>
occurrences of the expression within the html file <A href="../../libraries.htm">libs/libraries.htm</A>
was measured.&nbsp;</P>
<P>%html_search%</P>
<H3>Comparison 3: Simple Matches</H3>
<H3>Comparison 5: Simple Matches</H3>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
Expand Down
Loading