| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //////////////////////////////////////////////////////////////////////////////
- // Timer.h
- // =======
- // High Resolution Timer.
- // This timer is able to measure the elapsed time with 1 micro-second accuracy
- // in both Windows, Linux and Unix system
- //
- // AUTHOR: Song Ho Ahn ([email protected])
- // CREATED: 2003-01-13
- // UPDATED: 2006-01-13
- //
- // Copyright (c) 2003 Song Ho Ahn
- //////////////////////////////////////////////////////////////////////////////
- #ifndef HIGH_RESOLUTION_TIMER_H_DEF
- #define HIGH_RESOLUTION_TIMER_H_DEF
- #ifdef WIN32 // Windows system specific
- #include <windows.h>
- #else // Unix based system specific
- #include <sys/time.h>
- #endif
- class HighResolutionTimer
- {
- public:
- HighResolutionTimer(); // default constructor
- ~HighResolutionTimer(); // default destructor
- void start(); // start timer
- void stop(); // stop the timer
- double getElapsedTime(); // get elapsed time in second
- double getElapsedTimeInSec(); // get elapsed time in second (same as getElapsedTime)
- double getElapsedTimeInMilliSec(); // get elapsed time in milli-second
- double getElapsedTimeInMicroSec(); // get elapsed time in micro-second
- protected:
- private:
- double startTimeInMicroSec; // starting time in micro-second
- double endTimeInMicroSec; // ending time in micro-second
- int stopped; // stop flag
- #ifdef WIN32
- LARGE_INTEGER frequency; // ticks per second
- LARGE_INTEGER startCount; //
- LARGE_INTEGER endCount; //
- #else
- timeval startCount; //
- timeval endCount; //
- #endif
- };
- #endif // HIGH_RESOLUTION_TIMER_H_DEF
|