本文整理汇总了C++中Timer::GetMicroseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetMicroseconds方法的具体用法?C++ Timer::GetMicroseconds怎么用?C++ Timer::GetMicroseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetMicroseconds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_all_equal_commutative
void check_all_equal_commutative(const std::string& startsymbol, const std::vector<std::string>& inputs) {
Parser p;
int num_grammars = inputs.size();
auto nc_equations = p.free_parser(inputs[0]);
std::cout << "Eq (non-comm) : " << std::endl;
PrintEquations(nc_equations);
// Use appropriate semiring (has to be commutative!)
auto equations_fst = MakeCommEquationsAndMap(nc_equations, [](const FreeSemiring &c) -> SR {
auto srconv = SRConverter<SR>();
return c.Eval(srconv);
});
std::cout << "Eq (comm) : " << std::endl;
PrintEquations(equations_fst);
Timer timer;
timer.Start();
ValuationMap<SR> sol_fst = apply_solver<NewtonCL, CommutativePolynomial>(equations_fst, true, false, 0, false);
bool all_equal = true;
for(int i=1; i<num_grammars; i++) {
auto equations = MakeCommEquationsAndMap(p.free_parser(inputs[i]), [](const FreeSemiring &c) -> SR {
auto srconv = SRConverter<SR>();
return c.Eval(srconv);
});
ValuationMap<SR> sol = apply_solver<NewtonCL, CommutativePolynomial>(equations, true, false, 0, false);
if(startsymbol.compare("") == 0) {
if(sol[equations[0].first] != sol_fst[equations_fst[0].first]) {
std::cout << "[DIFF] Difference found for startsymbols (" << equations_fst[0].first << "," << equations[0].first << ")" << std::endl;
std::cout << "0:" << result_string(sol_fst) << std::endl << i << ":" << result_string(sol) << std::endl;
all_equal = false;
break;
}
}
else {
if(sol.find(Var::GetVarId(startsymbol)) == sol.end() || sol_fst.find(Var::GetVarId(startsymbol)) == sol_fst.end()) {
std::cout << "[ERROR] startsymbol (" << startsymbol << ") does not occur!"<< std::endl;
return;
}
else if(sol[Var::GetVarId(startsymbol)] != sol_fst[Var::GetVarId(startsymbol)]) {
std::cout << "[DIFF] Difference found for startsymbol (" << startsymbol << ")" << std::endl << "0:" << result_string(sol_fst)
<< std::endl << i << ":" << result_string(sol) << std::endl;
all_equal = false;
break;
}
}
}
if(all_equal) {
std::cout << "[EQUIV] All grammars equivalent modulo commutativity" << std::endl;
}
timer.Stop();
std::cout
<< "Total checking time:\t" << timer.GetMilliseconds().count()
<< " ms" << " ("
<< timer.GetMicroseconds().count()
<< "us)" << std::endl;
}
示例2: check_all_equal_lossy
void check_all_equal_lossy(const std::string& startsymbol, const std::vector<std::string>& inputs, int refinementDepth) {
int num_grammars = inputs.size();
Parser p;
auto eq_tmp = MapEquations(p.free_parser(inputs[0]), [](const FreeSemiring &c) -> LossyFiniteAutomaton {
auto srconv = SRConverter<LossyFiniteAutomaton>();
return c.Eval(srconv);
});
auto equations_fst = NCEquationsBase<LossyFiniteAutomaton>(eq_tmp.begin(), eq_tmp.end());
VarId S_1;
if(startsymbol.compare("") == 0) {
S_1 = equations_fst[0].first;
} else {
S_1 = Var::GetVarId(startsymbol);
}
Timer timer;
timer.Start();
bool all_equal = true;
for(int i=1; i<num_grammars; i++) {
auto eq_tmp2 = MapEquations(p.free_parser(inputs[i]), [](const FreeSemiring &c) -> LossyFiniteAutomaton {
auto srconv = SRConverter<LossyFiniteAutomaton>();
return c.Eval(srconv);
});
auto equations = NCEquationsBase<LossyFiniteAutomaton>(eq_tmp2.begin(), eq_tmp2.end());
VarId S_2;
if(startsymbol.compare("") == 0) {
S_2 = equations[0].first;
} else {
S_2 = Var::GetVarId(startsymbol);
}
auto witness = NonCommutativePolynomial<LossyFiniteAutomaton>::refineCourcelle(equations_fst, S_1, equations, S_1, refinementDepth);
if(witness != LossyFiniteAutomaton::null()) {
if(startsymbol.compare("") == 0) {
std::cout << "[DIFF] Difference found for startsymbols (" << equations_fst[0].first << "," << equations[0].first << ")" << std::endl;
}
else {
std::cout << "[DIFF] Difference found for startsymbols (" << S_1 << "," << S_2 << ")" << std::endl;
}
std::cout << "Witness: " << witness.string() << std::endl;
all_equal = false;
break;
}
}
if(all_equal) {
std::cout << "[EQUIV] All grammars equivalent modulo subword-closure" << std::endl;
}
timer.Stop();
std::cout
<< "Total checking time:\t" << timer.GetMilliseconds().count()
<< " ms" << " ("
<< timer.GetMicroseconds().count()
<< "us)" << std::endl;
}