本文整理汇总了C++中Timer::CPUTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::CPUTime方法的具体用法?C++ Timer::CPUTime怎么用?C++ Timer::CPUTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::CPUTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowTime
void ShowTime(Timer arg)
{
// double ftime; // real time
double ctime; // CPU time
// unsigned int ttime, rtime; // total and remaining real time (in seconds)
unsigned int tctime, rctime; // total and remaining CPU time (in seconds)
int day, hour, min, sec;
unsigned int rest;
// --- Write total and remaining estimated time -----------------------
// ftime = arg.GetRealTime();
ctime = arg.CPUTime();
// ttime = (unsigned int)((ftime*IterationNb)/IterationNo);
// rtime = (unsigned int)((ftime*(IterationNb-IterationNo))/IterationNo);
tctime = (unsigned int)((ctime*IterationNb)/IterationNo);
rctime = (unsigned int)((ctime*(IterationNb-IterationNo))/IterationNo);
// --- Show total time ------------------------------------------------
rest = tctime;
day = rest/86400;
rest %= 86400;
hour = rest/3600;
rest %= 3600;
min = rest/60;
rest %= 60;
sec = rest;
printf("\033[1A\033[1A");
if (tctime >= 86400)
printf("Total CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
if ((tctime < 86400)&&(tctime >= 3600))
printf("Total CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
if ((tctime < 3600)&&(tctime >= 60))
printf("Total CPU time (estimation) : %2d min %2d s \n", min, sec);
if (tctime < 60)
printf("Total CPU time (estimation) : %2d s \n", sec);
// --- Show remaining time ------------------------------------------------
rest = rctime;
day = rest/86400;
rest %= 86400;
hour = rest/3600;
rest %= 3600;
min = rest/60;
rest %= 60;
sec = rest;
if (rctime >= 86400)
printf("Remaining CPU time (estimation) : %5d day %2d h %2d min %2d s\n", day, hour, min, sec);
if ((rctime < 86400)&&(rctime >= 3600))
printf("Remaining CPU time (estimation) : %2d h %2d min %2d s \n", hour, min, sec);
if ((rctime < 3600)&&(rctime >= 60))
printf("Remaining CPU time (estimation) : %2d min %2d s \n", min, sec);
if (rctime < 60)
printf("Remaining CPU time (estimation) : %2d s \n", sec);
}