Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/xpressive/perf/regex_comparison.hpp @ 44

Last change on this file since 44 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.0 KB
Line 
1/*
2 *
3 * Copyright (c) 2002
4 * John Maddock
5 *
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 *
10 */
11
12
13#ifndef REGEX_COMPARISON_HPP
14#define REGEX_COMPARISON_HPP
15
16#include <string>
17#include <list>
18#include <boost/limits.hpp>
19
20//
21// globals:
22//
23extern bool time_boost;
24extern bool time_greta;
25extern bool time_safe_greta;
26extern bool time_dynamic_xpressive;
27extern bool time_static_xpressive;
28//extern bool time_posix;
29//extern bool time_pcre;
30
31extern bool test_matches;
32extern bool test_short_twain;
33extern bool test_long_twain;
34
35extern std::string xml_out_file;
36extern std::string xml_contents;
37
38
39int handle_argument(const std::string& what);
40int show_usage();
41void load_file(std::string& text, const char* file);
42void output_xml_results(bool show_description, const std::string& title, const std::string& filename);
43
44struct results
45{
46   double boost_time;
47   double greta_time;
48   double safe_greta_time;
49   double dynamic_xpressive_time;
50   double static_xpressive_time;
51   //double posix_time;
52   //double pcre_time;
53   double factor;
54   std::string expression;
55   std::string description;
56   results(const std::string& ex, const std::string& desc)
57      : boost_time(-1), 
58        greta_time(-1),
59        safe_greta_time(-1),
60        dynamic_xpressive_time(-1),
61        static_xpressive_time(-1),
62        //posix_time(-1),
63        //pcre_time(-1),
64        factor((std::numeric_limits<double>::max)()),
65        expression(ex), 
66        description(desc)
67   {}
68   void finalise()
69   {
70      if((boost_time >= 0) && (boost_time < factor))
71         factor = boost_time;
72      if((greta_time >= 0) && (greta_time < factor))
73         factor = greta_time;
74      if((safe_greta_time >= 0) && (safe_greta_time < factor))
75          factor = safe_greta_time;
76      if((dynamic_xpressive_time >= 0) && (dynamic_xpressive_time < factor))
77          factor = dynamic_xpressive_time;
78      if((static_xpressive_time >= 0) && (static_xpressive_time < factor))
79          factor = static_xpressive_time;
80      //if((posix_time >= 0) && (posix_time < factor))
81      //   factor = posix_time;
82      //if((pcre_time >= 0) && (pcre_time < factor))
83      //   factor = pcre_time;
84      if((factor >= 0) && (factor < factor))
85         factor = factor;
86   }
87};
88
89extern std::list<results> result_list;
90
91
92namespace b {
93// boost tests:
94double time_match(const std::string& re, const std::string& text);
95double time_find_all(const std::string& re, const std::string& text);
96}
97//namespace posix {
98//// posix tests:
99//double time_match(const std::string& re, const std::string& text);
100//double time_find_all(const std::string& re, const std::string& text);
101//
102//}
103//namespace pcr {
104//// pcre tests:
105//double time_match(const std::string& re, const std::string& text);
106//double time_find_all(const std::string& re, const std::string& text);
107//
108//}
109namespace g {
110// greta tests:
111double time_match(const std::string& re, const std::string& text);
112double time_find_all(const std::string& re, const std::string& text);
113}
114namespace gs {
115// safe greta tests:
116double time_match(const std::string& re, const std::string& text);
117double time_find_all(const std::string& re, const std::string& text);
118}
119namespace dxpr {
120// dynamic xpressive tests:
121double time_match(const std::string& re, const std::string& text);
122double time_find_all(const std::string& re, const std::string& text);
123}
124namespace sxpr {
125// static xpressive tests:
126double time_match(const std::string& re, const std::string& text);
127double time_find_all(const std::string& re, const std::string& text);
128}
129void test_match(const std::string& re, const std::string& text, const std::string& description);
130void test_find_all(const std::string& re, const std::string& text, const std::string& description);
131inline void test_match(const std::string& re, const std::string& text)
132{ test_match(re, text, text); }
133inline void test_find_all(const std::string& re, const std::string& text)
134{ test_find_all(re, text, ""); }
135
136
137#define REPEAT_COUNT 10
138
139#endif
Note: See TracBrowser for help on using the repository browser.