Added new docs,

Moved source more into line with the std lib proposal.


[SVN r18292]
This commit is contained in:
John Maddock committed 2003-04-23 10:49:57 +00:00
1 parent c233f06654
commit c8f2ed3bdb
111 files changed
+17582 -7758

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
subproject libs/regex/performance ;
SOURCES = command_line main time_boost time_greta time_localised_boost time_pcre time_posix time_safe_greta ;
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 = <define>BOOST_HAS_POSIX=1 <include>$(HS_REGEX_PATH) ;
}
else if $(USE_POSIX)
{
POSIX_OPTS = <define>BOOST_HAS_POSIX=1 ;
}
if $(PCRE_PATH)
{
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 <find-library>pcre ;
}
exe regex_comparison :
$(SOURCES).cpp
$(HS_SOURCES)
$(PCRE_SOURCES)
<lib>../build/boost_regex
<lib>../../test/build/boost_prg_exec_monitor
:
<include>$(BOOST_ROOT)
<define>BOOST_REGEX_NO_LIB=1
<define>BOOST_REGEX_STATIC_LINK=1
$(POSIX_OPTS)
$(PCRE_OPTS)
;
+48 -3
View File
@@ -6,6 +6,8 @@
#include <sstream>
#include <stdexcept>
#include <iterator>
#include <boost/regex.hpp>
#include <boost/version.hpp>
#include "regex_comparison.hpp"
//
@@ -190,6 +192,13 @@ void print_result(std::ostream& os, double time, double best)
os << "</td>";
}
std::string html_quote(const std::string& in)
{
static const boost::regex e("(<)|(>)|(&)|(\")");
static const std::string format("(?1&lt;)(?2&gt;)(?3&amp;)(?4&quot;)");
return regex_replace(in, e, format);
}
void output_html_results(bool show_description, const std::string& tagname)
{
std::stringstream os;
@@ -230,9 +239,9 @@ void output_html_results(bool show_description, const std::string& tagname)
last = result_list.end();
while(first != last)
{
os << "<tr><td><code>" << first->expression << "</code></td>";
os << "<tr><td><code>" << html_quote(first->expression) << "</code></td>";
if(show_description)
os << "<td>" << first->description << "</td>";
os << "<td>" << html_quote(first->description) << "</td>";
#if defined(BOOST_HAS_GRETA)
if(time_greta == true)
print_result(os, first->greta_time, first->factor);
@@ -264,7 +273,7 @@ void output_html_results(bool show_description, const std::string& tagname)
std::string result = os.str();
unsigned int pos = html_contents.find(tagname);
std::string::size_type pos = html_contents.find(tagname);
if(pos != std::string::npos)
{
html_contents.replace(pos, tagname.size(), result);
@@ -275,6 +284,42 @@ 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, BOOST_STRINGIZE(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
}
//
// now right the output to file:
//
std::ofstream os(html_out_file.c_str());
os << html_contents;
}
+62 -57
View File
@@ -1,59 +1,64 @@
<html>
<head>
<title>Regular Expression Performance Comparison</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The Boost and GRETA regular expression libraries have slightly different
interfaces, and it has been suggested that GRETA's interface allows for a more
efficient implementation. The following tables provide comparisons between:</p>
<p><a href="http://research.microsoft.com/projects/greta">GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<p>
Times were obtained on a 2.8GHz Pentium&nbsp;4 PC running Windows XP, and the
code was compiled with Visual C++ 7.1 with all optimisations turned on. 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 <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. 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.</p>
<h3>Comparison 1: Long Search</h3>
<p>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
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<P>%long_twain_search%</P>
<h3>Comparison 2: Medium Sized Search</h3>
<p>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).&nbsp;</p>
<P>%short_twain_search%</P>
<H3>Comparison 3:&nbsp;C++ Code&nbsp;Search</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <A href="../../../boost/crc.hpp">
boost/crc.hpp</A>&nbsp;was measured.&nbsp;</P>
<P>%code_search%</P>
<H3>
<H3>Comparison 4: HTML Document Search</H3>
</H3>
<P>For each of the following regular expressions the time taken to find all
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>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<P>%short_matches%</P>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
<head>
<title>Regular Expression Performance Comparison</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
</head>
<body bgcolor="#ffffff" link="#0000ff" vlink="#800080">
<h2>Regular Expression Performance Comparison</h2>
<p>The Boost and GRETA regular expression libraries have slightly different
interfaces, and it has been suggested that GRETA's interface allows for a more
efficient implementation. The following tables provide comparisons between:</p>
<p><a href="http://research.microsoft.com/projects/greta">GRETA</a>.</p>
<p><a href="http://www.boost.org/">The Boost regex library</a>.</p>
<p><a href="http://arglist.com/regex/">Henry Spencer's regular expression library</a>
- this is provided for comparison as a typical non-backtracking implementation.</p>
<H3>Details</H3>
<P>Machine: Intel Pentium 4 2.8GHz PC.</P>
<P>Compiler: %compiler%.</P>
<P>C++ Standard Library: %library%.</P>
<P>OS: %os%.</P>
<P>Boost version: %boost%.</P>
<P>PCRE version: %pcre%.</P>
<P>
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 <a href="http://www.regxlib.com/">Library of
Regular Expressions</a>. 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.</P>
<h3>Comparison 1: Long Search</h3>
<p>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
(<a href="ftp://ibiblio.org/pub/docs/books/gutenberg/etext02/mtent12.zip">mtent12.txt</a>
from <a href="http://promo.net/pg/">Project Gutenberg</a>, 19Mb).&nbsp;</p>
<P>%long_twain_search%</P>
<h3>Comparison 2: Medium Sized Search</h3>
<p>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).&nbsp;</p>
<P>%short_twain_search%</P>
<H3>Comparison 3:&nbsp;C++ Code&nbsp;Search</H3>
<P>For each of the following regular expressions the time taken to find all
occurrences of the expression within the C++ source file <A href="../../../boost/crc.hpp">
boost/crc.hpp</A>&nbsp;was measured.&nbsp;</P>
<P>%code_search%</P>
<H3>
<H3>Comparison 4: HTML Document Search</H3>
</H3>
<P>For each of the following regular expressions the time taken to find all
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>
<p>
For each of the following regular expressions the time taken to match against
the text indicated was measured.&nbsp;</p>
<P>%short_matches%</P>
<hr>
<p>Copyright John Maddock April 2003, all rights reserved.</p>
</body>
</html>
+1 -1
View File
@@ -232,7 +232,7 @@ int cpp_main(int argc, char * argv[])
if(test_long_twain)
{
load_file(file_contents, "mtent12.txt");
load_file(file_contents, "mtent13.txt");
test_find_all("Twain", file_contents);
test_find_all("Huck[[:alpha:]]+", file_contents);
+2 -2
View File
@@ -21,7 +21,7 @@ namespace b{
double time_match(const std::string& re, const std::string& text, bool icase)
{
boost::regex e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;
@@ -59,7 +59,7 @@ bool dummy_grep_proc(const boost::smatch&)
double time_find_all(const std::string& re, const std::string& text, bool icase)
{
boost::regex e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;
+2 -2
View File
@@ -21,7 +21,7 @@ namespace bl{
double time_match(const std::string& re, const std::string& text, bool icase)
{
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;
@@ -59,7 +59,7 @@ bool dummy_grep_proc(const boost::smatch&)
double time_find_all(const std::string& re, const std::string& text, bool icase)
{
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regbase::perl | boost::regbase::icase : boost::regbase::perl));
boost::reg_expression<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
boost::smatch what;
boost::timer tim;
int iter = 1;