/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + S t o p T i m e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % StopTimer() stops the stopwatch. % % The format of the StopTimer method is: % % void StopTimer(TimerInfo *time_info) % % A description of each parameter follows. % % o time_info: Timer statistics structure. % */ static void StopTimer(TimerInfo *time_info) { assert(time_info != (TimerInfo *) NULL); assert(time_info->signature == MagickSignature); time_info->elapsed.stop=ElapsedTime(); time_info->user.stop=UserTime(); if (time_info->state == RunningTimerState) { time_info->user.total+=time_info->user.stop- time_info->user.start+MagickEpsilon; time_info->elapsed.total+=time_info->elapsed.stop- time_info->elapsed.start+MagickEpsilon; } time_info->state=StoppedTimerState; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + S t a r t T i m e r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % StartTimer() starts the stopwatch. % % The format of the StartTimer method is: % % void StartTimer(TimerInfo *time_info,const MagickBooleanType reset) % % A description of each parameter follows. % % o time_info: Timer statistics structure. % % o reset: If reset is MagickTrue, then the stopwatch is reset prior to % starting. If reset is MagickFalse, then timing is continued without % resetting the stopwatch. % */ MagickExport void StartTimer(TimerInfo *time_info,const MagickBooleanType reset) { assert(time_info != (TimerInfo *) NULL); assert(time_info->signature == MagickSignature); if (reset != MagickFalse) { /* Reset the stopwatch before starting it. */ time_info->user.total=0.0; time_info->elapsed.total=0.0; } if (time_info->state != RunningTimerState) { time_info->elapsed.start=ElapsedTime(); time_info->user.start=UserTime(); } time_info->state=RunningTimerState; }
inline double StopWatch::RealTime() { #if (MFEM_TIMER_TYPE == 0) return UserTime(); #elif (MFEM_TIMER_TYPE == 1) clock_t curr_rtime, curr_utime, curr_stime; clock_t rtime = real_time; if (Running) { Current(&curr_rtime, &curr_utime, &curr_stime); rtime += (curr_rtime - start_rtime); } return (double)(rtime) / my_CLK_TCK; #elif (MFEM_TIMER_TYPE == 2) if (Running) { struct timespec curr_rtime; GetRealTime(curr_rtime); return ((real_time.tv_sec + (curr_rtime.tv_sec - start_rtime.tv_sec)) + 1e-9*(real_time.tv_nsec + (curr_rtime.tv_nsec - start_rtime.tv_nsec))); } else { return real_time.tv_sec + 1e-9*real_time.tv_nsec; } #elif (MFEM_TIMER_TYPE == 3) LARGE_INTEGER curr_rtime, rtime = real_time; if (Running) { QueryPerformanceCounter(&curr_rtime); rtime.QuadPart += (curr_rtime.QuadPart - start_rtime.QuadPart); } return (double)(rtime.QuadPart) / frequency.QuadPart; #endif }