00001
00002
00003
00004
00005
00006
00007
00008 #ifndef TIMER_H_
00009 #define TIMER_H_
00010
00011 #ifdef WINDOWS // Windows
00012 #include <windows.h>
00013 #else // Unix
00014 #include <sys/time.h>
00015 #endif
00016
00017
00018 class Timer
00019 {
00020 private:
00021 double startTimeInMicroSec;
00022 double endTimeInMicroSec;
00023 bool ticking;
00024 #ifdef WINDOWS
00025 LARGE_INTEGER frequency;
00026 LARGE_INTEGER startCount;
00027 LARGE_INTEGER endCount;
00028 #else
00029 timeval startCount;
00030 timeval endCount;
00031 #endif
00032
00033
00034
00035 public:
00036 Timer();
00037 ~Timer();
00038
00039 void start();
00040 void stop();
00041 double getElapsedTimeInMilliSec();
00042 double getElapsedTimeInMicroSec();
00043 double getTimerSnapshot();
00044 };
00045
00046 #endif