45 if (gettimeofday(&stTvTimeStart, (
struct timezone *)0) < 0) {
46 std::cerr <<
"gettimeofday() error in ParaSysTimer::start" << std::endl;
49 if (getrusage(RUSAGE_SELF, &stRuStart) < 0) {
50 std::cerr <<
"getrusage() error in ParaSysTimer::start" << std::endl;
57 if( ! GetProcessTimes(
67 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
70 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
76 std::cerr <<
"GetProcessTimes() error in ParaSysTimer::start errcode = "
77 << lpMsgBuf << std::endl;
84 if ((lTimeStart = times(&stTmsStart)) == -1) {
85 std::cerr <<
"times() error inin ParaSysTimer::start" << std::endl;
98 if (getrusage(RUSAGE_SELF, &stRuStop) < 0) {
99 std::cerr <<
"getrusage() error in ParaSysTimer::stop" << std::endl;
102 if (gettimeofday(&stTvTimeStop, (
struct timezone *) 0) < 0) {
103 std::cerr <<
"gettimeofday() error in ParaSysTimer::stop" << std::endl;
109 if( ! GetProcessTimes(
116 std::cerr <<
"GetProcessTimes() error in ParaSysTimer::start" << std::endl;
123 if ((lTimeStop = times(&stTmsStop)) == -1) {
124 std::cerr <<
"times() error in ParaSysTimer::stop" << std::endl;
138 double dStart = ((double) stTvTimeStart.tv_sec) * 1000000.0
139 + stTvTimeStart.tv_usec;
140 double dSeconds = dStart/1000000.0;
145 dSeconds = timebStart.time
146 + (double)(timebStart.millitm)/1000;
151 double dSeconds = (double)lTimeStart/(
double)TICKS;
161 struct timeval stTempTvTimeStop;
162 struct rusage stTempRuStop;
164 if (getrusage(RUSAGE_SELF, &stTempRuStop) < 0) {
165 std::cerr <<
"getrusage() error in ParaSysTimer::getRTimeInterval" << std::endl;
168 if (gettimeofday(&stTempTvTimeStop, (
struct timezone *) 0) < 0) {
169 std::cerr <<
"gettimeofday() error in ParaSysTimer::getRTimeInterval" << std::endl;
173 double dStart = ((double) stTvTimeStart.tv_sec) * 1000000.0
174 + stTvTimeStart.tv_usec;
175 double dStop = ((double) stTempTvTimeStop.tv_sec) * 1000000.0
176 + stTempTvTimeStop.tv_usec;
177 double dSeconds = (dStop - dStart)/1000000.0;
181 struct _timeb timebTempStop;
183 FILETIME ftTempCreationTime, ftTempExitTime,
184 ftTempKernelTimeStop, ftTempUserTimeStop;
186 if( ! GetProcessTimes(
190 &ftTempKernelTimeStop,
193 std::cerr <<
"GetProcessTimes() error in ParaSysTimer::start" << std::endl;
196 _ftime(&timebTempStop);
199 if ( timebTempStop.millitm - timebStart.millitm >= 0 ){
200 dSeconds = (timebTempStop.time - timebStart.time)
201 + (
double)(timebTempStop.millitm - timebStart.millitm)/1000;
203 dSeconds = (timebTempStop.time - timebStart.time - 1)
204 + (
double)(timebTempStop.millitm + 1000
205 - timebStart.millitm)/1000;
211 struct tms stTempTmsStop;
213 if ((lTempTimeStop = times(&stTempTmsStop)) == -1) {
214 std::cerr <<
"times() error in ParaSysTimer::stop" << std::endl;
218 double dSeconds = (double)(lTempTimeStop - lTimeStart)/(double)TICKS;
228 double dStart = ((double) stTvTimeStart.tv_sec) * 1000000.0
229 + stTvTimeStart.tv_usec;
230 double dStop = ((double) stTvTimeStop.tv_sec) * 1000000.0
231 + stTvTimeStop.tv_usec;
232 double dSeconds = (dStop - dStart)/1000000.0;
237 if ( timebStop.millitm - timebStart.millitm >= 0 ){
238 dSeconds = (timebStop.time - timebStart.time)
239 + (
double)(timebStop.millitm - timebStart.millitm)/1000;
241 dSeconds = (timebStop.time - timebStart.time - 1)
242 + (
double)(timebStop.millitm + 1000
243 - timebStart.millitm)/1000;
248 double dSeconds = (double)(lTimeStop - lTimeStart)/(double)TICKS;
257 double dStart = ((double) stRuStart.ru_utime.tv_sec) * 1000000.0
258 + stRuStart.ru_utime.tv_usec;
259 double dStop = ((double) stRuStop.ru_utime.tv_sec) * 1000000.0
260 + stRuStop.ru_utime.tv_usec;
261 double dSeconds = (dStop - dStart)/1000000.0;
266 __int64 i64Start, i64Stop;
267 i64Start = ftUserTimeStart.dwHighDateTime;
269 i64Start |= ftUserTimeStart.dwLowDateTime;
270 i64Stop = ftUserTimeStop.dwHighDateTime;
272 i64Stop |= ftUserTimeStop.dwLowDateTime;
274 dSeconds = (double)( (i64Stop - i64Start) ) / 10000000.0;
278 double dSeconds = (double)(stTmsStop.tms_utime - stTmsStart.tms_utime)/
289 double dStart = ((double) stRuStart.ru_stime.tv_sec) * 1000000.0
290 + stRuStart.ru_stime.tv_usec;
291 double dStop = ((double)stRuStop.ru_stime.tv_sec) * 1000000.0
292 + stRuStop.ru_stime.tv_usec;
293 double dSeconds = (dStop - dStart)/1000000.0;
298 __int64 i64Start, i64Stop;
299 i64Start = ftKernelTimeStart.dwHighDateTime;
301 i64Start |= ftKernelTimeStart.dwLowDateTime;
302 i64Stop = ftKernelTimeStop.dwHighDateTime;
304 i64Stop |= ftKernelTimeStop.dwLowDateTime;
306 dSeconds = (double)( (i64Stop - i64Start) ) / 10000000.0;
310 double dSeconds = (double)(stTmsStop.tms_stime - stTmsStart.tms_stime)/
double getUTime(void)
get user time between start timne and stop time
double getSTime(void)
get system time between start timne and stop time
void stop(void)
stop timer
double getStartTime(void)
get start time
double getRTimeInterval(void)
get elapsed time from start time
double getRTime(void)
get real time between start timne and stop time