当前位置: 首页>>代码示例>>C++>>正文


C++ Timer::CPUTime方法代码示例

本文整理汇总了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);

}
开发者ID:waveletApplications,项目名称:carmen,代码行数:68,代码来源:ShowTime.cpp


注:本文中的Timer::CPUTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。