本文整理汇总了C++中timer::elapsed_time方法的典型用法代码示例。如果您正苦于以下问题:C++ timer::elapsed_time方法的具体用法?C++ timer::elapsed_time怎么用?C++ timer::elapsed_time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer
的用法示例。
在下文中一共展示了timer::elapsed_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Progress
/*!
Progress(theTimer, nodenum, numnodes, thePercent, 5, theTime, 60, "Reading dumpfile");
if either delta is exceeded, increase oPercent & oTime and report the progress
return 1 if something is printed out, else return 0
*/
int Progress(timer &iTimer, double iNum, double iMax,
double &oPercent, double iPercentDelta,
double &oTime, double iTimeDelta, string iMsg) {
double percent = iNum/iMax*100.0;
double newtime = iTimer.elapsed_time();
if (iNum == iMax || percent - oPercent > iPercentDelta || newtime-oTime > iTimeDelta) {
double remaining = (iMax-iNum)/(iNum!=0?iNum:1)*newtime;
double persec= iNum/newtime;
char msg[4096];
sprintf(msg, "\r%s: %g%%; %g/%g items, %g secs, %g/sec, left: %g", /*datestring(), */iMsg.c_str(), percent, iNum, iMax, newtime, persec, remaining);
cerr << msg << flush;
oPercent=percent;
oTime=newtime;
return 1;
}
return 0;
}