本文整理汇总了C++中Timer::GetMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetMilliseconds方法的具体用法?C++ Timer::GetMilliseconds怎么用?C++ Timer::GetMilliseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetMilliseconds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: TimeOfImpact
//.........这里部分代码省略.........
// runs out of iterations.
if (s1 < target - tolerance)
{
output->state = TOIOutput::e_failed;
output->t = t1;
done = true;
break;
}
// Check for touching
if (s1 <= target + tolerance)
{
// Victory! t1 should hold the TOI (could be 0.0).
output->state = TOIOutput::e_touching;
output->t = t1;
done = true;
break;
}
// Compute 1D root of: f(x) - target = 0
int32 rootIterCount = 0;
float32 a1 = t1, a2 = t2;
for (;;)
{
// Use a mix of the secant rule and bisection.
float32 t;
if (rootIterCount & 1)
{
// Secant rule to improve convergence.
t = a1 + (target - s1) * (a2 - a1) / (s2 - s1);
}
else
{
// Bisection to guarantee progress.
t = 0.5f * (a1 + a2);
}
++rootIterCount;
++b2_toiRootIters;
float32 s = fcn.Evaluate(indexA, indexB, t);
if (Abs(s - target) < tolerance)
{
// t2 holds a tentative value for t1
t2 = t;
break;
}
// Ensure we continue to bracket the root.
if (s > target)
{
a1 = t;
s1 = s;
}
else
{
a2 = t;
s2 = s;
}
if (rootIterCount == 50)
{
break;
}
}
b2_toiMaxRootIters = Max(b2_toiMaxRootIters, rootIterCount);
++pushBackIter;
if (pushBackIter == maxPolygonVertices)
{
break;
}
}
++iter;
++b2_toiIters;
if (done)
{
break;
}
if (iter == k_maxIterations)
{
// Root finder got stuck. Semi-victory.
output->state = TOIOutput::e_failed;
output->t = t1;
break;
}
}
b2_toiMaxIters = Max(b2_toiMaxIters, iter);
float32 time = timer.GetMilliseconds();
b2_toiMaxTime = Max(b2_toiMaxTime, time);
b2_toiTime += time;
}