diff --git a/performance/command_line.cpp b/performance/command_line.cpp index 2e79cdb6..6b188c51 100644 --- a/performance/command_line.cpp +++ b/performance/command_line.cpp @@ -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 << "PCRE"; +#endif +#ifdef BOOST_HAS_XPRESSIVE + if(time_xpressive == true) + os << "Dynamic Xpressive"; #endif os << "\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 << "\n"; ++first; @@ -400,6 +417,12 @@ std::string get_averages_table() { os << "PCRE"; } +#endif +#ifdef BOOST_HAS_XPRESSIVE + if(time_xpressive == true) + { + os << "Dynamic Xpressive"; + } #endif os << "\n"; @@ -416,14 +439,18 @@ std::string get_averages_table() #if defined(BOOST_HAS_POSIX) if(time_boost == true) os << "" << (boost_total / boost_test_count) << "\n"; +#endif if(time_localised_boost == true) os << "" << (locale_boost_total / locale_boost_test_count) << "\n"; -#endif if(time_posix == true) os << "" << (posix_total / posix_test_count) << "\n"; #if defined(BOOST_HAS_PCRE) if(time_pcre == true) os << "" << (pcre_total / pcre_test_count) << "\n"; +#endif +#if defined(BOOST_HAS_XPRESSIVE) + if(time_xpressive == true) + os << "" << (xpressive_total / xpressive_test_count) << "\n"; #endif os << "\n"; os << "\n"; diff --git a/performance/time_boost.cpp b/performance/time_boost.cpp index 2e7dc24c..b6ca08af 100644 --- a/performance/time_boost.cpp +++ b/performance/time_boost.cpp @@ -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; diff --git a/performance/time_dynamic_xpressive.cpp b/performance/time_dynamic_xpressive.cpp index 0e624037..297a59d6 100644 --- a/performance/time_dynamic_xpressive.cpp +++ b/performance/time_dynamic_xpressive.cpp @@ -13,6 +13,7 @@ #ifdef BOOST_HAS_XPRESSIVE #include +#include #include #include @@ -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; + } } } diff --git a/performance/time_localised_boost.cpp b/performance/time_localised_boost.cpp index 33266e2a..d2a27bf4 100644 --- a/performance/time_localised_boost.cpp +++ b/performance/time_localised_boost.cpp @@ -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 > 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 > 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;