timer.cc

来自「linux下的一个分组遗传算法」· CC 代码 · 共 76 行

CC
76
字号
//// timer.cc - A stopwatch//// author: J.I.v.Hemert// last updated : 10-10-1997//// This file implements the class TimerC.//#include "timer.h"void TimerC::Reset (){#ifdef  Linux	struct timeb tmp;	ftime (&tmp);	start = tmp.time;#endif#ifdef IRIX	start = time (0);#endif} // Reset ()int TimerC::GetTime (){#ifndef SunOS#ifdef Linux	struct timeb tmp;	ftime (&tmp);	return (tmp.time);#endif#ifdef IRIX	return (time (0));#endif#else	return (0);#endif} // GetTime ()void TimerC::Print (ofstream & stream){#ifndef SunOS	double elapsed;#if defined(Linux)	struct timeb tmp;	ftime (&tmp);	elapsed = difftime (tmp.time, start);#endif#ifdef IRIX	time_t tmp;	tmp = time(0);	elapsed = difftime (tmp, start);#endif	stream << (int)(elapsed / 3600) << ":"			<< (int)(elapsed / 60) % 60 << ":"			 << (int)elapsed % 60;#else	stream << "not implemented";#endif} // Print ()// eof timer.cc

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?