7 static map<const char*, long> occurances_in_failed_query;
8 static map<const char*, long> occurances_in_ok_query;
9 static map<const char*, long> retries;
10 static map<const char*, long> limited;
11 static map<const char*, long> failed;
13 impedance_visitor::impedance_visitor(map<const char*, long> &occured)
17 void impedance_visitor::visit(
struct prod *p)
19 found[
typeid(*p).name()] =
true;
22 impedance_visitor::~impedance_visitor()
24 for(
auto pair : found)
25 _occured[pair.first]++;
28 void impedance_feedback::executed(
prod &query)
43 bool matched(
const char *name)
45 if (100 > occurances_in_failed_query[name])
47 double error_rate = (double)occurances_in_failed_query[name]
48 / (occurances_in_failed_query[name] + occurances_in_ok_query[name]);
49 if (error_rate > 0.99)
56 cerr <<
"impedance report: " << endl;
57 for (
auto pair : occurances_in_failed_query) {
58 cerr <<
" " << pretty_type(pair.first) <<
": " <<
59 pair.second <<
"/" << occurances_in_ok_query[pair.first]
61 if (!matched(pair.first))
62 cerr <<
" -> BLACKLISTED";
67 void report(std::ostream &out)
69 out <<
"{\"impedance\": [ " << endl;
71 for (
auto pair = occurances_in_failed_query.begin();
72 pair != occurances_in_failed_query.end();
74 out <<
"{\"prod\": \"" << pretty_type(pair->first) <<
"\","
75 <<
"\"bad\": " << pair->second <<
", "
76 <<
"\"ok\": " << occurances_in_ok_query[pair->first] <<
", "
77 <<
"\"limited\": " << limited[pair->first] <<
", "
78 <<
"\"failed\": " << failed[pair->first] <<
", "
79 <<
"\"retries\": " << retries[pair->first] <<
"} ";
81 if (next(pair) != occurances_in_failed_query.end())
87 void retry(
const char *p)
92 void limit(
const char *p)
97 void fail(
const char *p)
feedback to the grammar about failed productions
Base class for AST nodes.
virtual void accept(prod_visitor *v)
Visitor pattern for walking the AST.