mirror of
https://github.com/boostorg/regex.git
synced 2025-07-12 20:06:38 +02:00
Updated to get xpressive tests to run correctly, and to use regex_iterators for searching.
[SVN r31018]
This commit is contained in:
@ -54,12 +54,14 @@ double boost_total = 0;
|
||||
double locale_boost_total = 0;
|
||||
double posix_total = 0;
|
||||
double pcre_total = 0;
|
||||
double xpressive_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;
|
||||
|
||||
int handle_argument(const std::string& what)
|
||||
{
|
||||
@ -261,6 +263,10 @@ void output_html_results(bool show_description, const std::string& tagname)
|
||||
#ifdef BOOST_HAS_PCRE
|
||||
if(time_pcre == true)
|
||||
os << "<td><strong>PCRE</strong></td>";
|
||||
#endif
|
||||
#ifdef BOOST_HAS_XPRESSIVE
|
||||
if(time_xpressive == true)
|
||||
os << "<td><strong>Dynamic Xpressive</strong></td>";
|
||||
#endif
|
||||
os << "</tr>\n";
|
||||
|
||||
@ -305,6 +311,7 @@ void output_html_results(bool show_description, const std::string& tagname)
|
||||
++boost_test_count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(time_localised_boost == true)
|
||||
{
|
||||
print_result(os, first->localised_boost_time, first->factor);
|
||||
@ -314,7 +321,6 @@ void output_html_results(bool show_description, const std::string& tagname)
|
||||
++locale_boost_test_count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(time_posix == true)
|
||||
{
|
||||
print_result(os, first->posix_time, first->factor);
|
||||
@ -334,6 +340,17 @@ void output_html_results(bool show_description, const std::string& tagname)
|
||||
++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
|
||||
os << "</tr>\n";
|
||||
++first;
|
||||
@ -400,6 +417,12 @@ std::string get_averages_table()
|
||||
{
|
||||
os << "<td><strong>PCRE</strong></td>";
|
||||
}
|
||||
#endif
|
||||
#ifdef BOOST_HAS_XPRESSIVE
|
||||
if(time_xpressive == true)
|
||||
{
|
||||
os << "<td><strong>Dynamic Xpressive</strong></td>";
|
||||
}
|
||||
#endif
|
||||
os << "</tr>\n";
|
||||
|
||||
@ -416,14 +439,18 @@ std::string get_averages_table()
|
||||
#if defined(BOOST_HAS_POSIX)
|
||||
if(time_boost == true)
|
||||
os << "<td>" << (boost_total / boost_test_count) << "</td>\n";
|
||||
#endif
|
||||
if(time_localised_boost == true)
|
||||
os << "<td>" << (locale_boost_total / locale_boost_test_count) << "</td>\n";
|
||||
#endif
|
||||
if(time_posix == true)
|
||||
os << "<td>" << (posix_total / posix_test_count) << "</td>\n";
|
||||
#if defined(BOOST_HAS_PCRE)
|
||||
if(time_pcre == true)
|
||||
os << "<td>" << (pcre_total / pcre_test_count) << "</td>\n";
|
||||
#endif
|
||||
#if defined(BOOST_HAS_XPRESSIVE)
|
||||
if(time_xpressive == true)
|
||||
os << "<td>" << (xpressive_total / xpressive_test_count) << "</td>\n";
|
||||
#endif
|
||||
os << "</tr>\n";
|
||||
os << "</table>\n";
|
||||
|
@ -53,6 +53,13 @@ double time_match(const std::string& re, const std::string& text, bool icase)
|
||||
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::regex e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
|
||||
@ -67,7 +74,9 @@ double time_find_all(const std::string& re, const std::string& text, bool icase)
|
||||
tim.restart();
|
||||
for(counter = 0; counter < iter; ++counter)
|
||||
{
|
||||
boost::regex_grep(&dummy_grep_proc, text, e);
|
||||
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;
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#ifdef BOOST_HAS_XPRESSIVE
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <boost/timer.hpp>
|
||||
#include <boost/xpressive/xpressive.hpp>
|
||||
|
||||
@ -21,6 +22,7 @@ namespace dxpr
|
||||
|
||||
double time_match(const std::string& re, const std::string& text, bool icase)
|
||||
{
|
||||
try{
|
||||
boost::xpressive::sregex e;
|
||||
e = (icase ?
|
||||
boost::xpressive::sregex(boost::xpressive::sregex::compile(re))
|
||||
@ -56,6 +58,12 @@ double time_match(const std::string& re, const std::string& text, bool icase)
|
||||
result = (std::min)(run, result);
|
||||
}
|
||||
return result / iter;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cout << "Exception: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
struct noop
|
||||
@ -67,6 +75,7 @@ struct noop
|
||||
|
||||
double time_find_all(const std::string& re, const std::string& text, bool icase)
|
||||
{
|
||||
try{
|
||||
boost::xpressive::sregex e;
|
||||
e = (icase ?
|
||||
boost::xpressive::sregex(boost::xpressive::sregex::compile(re))
|
||||
@ -106,6 +115,12 @@ double time_find_all(const std::string& re, const std::string& text, bool icase)
|
||||
result = (std::min)(run, result);
|
||||
}
|
||||
return result / iter;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cout << "Exception: " << e.what() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,6 +53,13 @@ double time_match(const std::string& re, const std::string& text, bool icase)
|
||||
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<char, boost::cpp_regex_traits<char> > e(re, (icase ? boost::regex::perl | boost::regex::icase : boost::regex::perl));
|
||||
@ -67,7 +74,12 @@ double time_find_all(const std::string& re, const std::string& text, bool icase)
|
||||
tim.restart();
|
||||
for(counter = 0; counter < iter; ++counter)
|
||||
{
|
||||
boost::regex_grep(&dummy_grep_proc, text, e);
|
||||
boost::regex_iterator<
|
||||
std::string::const_iterator,
|
||||
char,
|
||||
boost::cpp_regex_traits<char> > 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;
|
||||
|
Reference in New Issue
Block a user