#ifndef __TIMER_H__ #define __TIMER_H__ #include "types.h" #include "debug.h" const long ciTimer_sec_frac = 1000000; ////////////////////////////////////////////////////////////////////////////// // TimeValue // class TimeValue { public: TimeValue(); ~TimeValue(); public: void RecordTime(); TimeValue operator+(const TimeValue& tv); TimeValue operator-(const TimeValue& tv); public: inline DOUBLE GetSeconds(); public: long m_sec; long m_usec; }; inline DOUBLE TimeValue::GetSeconds() { return (DOUBLE)m_sec + (DOUBLE)m_usec/(DOUBLE)ciTimer_sec_frac; } ////////////////////////////////////////////////////////////////////////////// // Timer // class Timer { public: Timer(); ~Timer(); public: void Reset(); void Start(); void Stop(); public: inline DOUBLE GetSeconds(); public: BOOL m_bRunning; TimeValue m_tvStart; TimeValue m_tvStop; DOUBLE m_dSecTotal; }; inline DOUBLE Timer::GetSeconds() { ASSERT( !m_bRunning ); return m_dSecTotal; } inline void SecondsToMinutes(long *pMinutes, long *pSeconds, long seconds) { if ( pMinutes != NULL ) { *pMinutes = seconds / 60; } if ( pSeconds != NULL ) { *pSeconds = seconds % 60; } } #endif // __TIMER_H__