00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _CLOCK_H
00024 #define _CLOCK_H
00025
00026 #ifdef _WIN32
00027 #pragma warning(disable:4786)
00028 #include <windows.h>
00029 #else
00030 #include <sys/time.h>
00031 #endif
00032 #include <string>
00033
00034
00036
00037 class Clock
00038 {
00039 public:
00040 Clock();
00041 ~Clock();
00042
00043 void PrintDiff(const std::string& = "");
00044 void Reset() {
00045 #ifdef _WIN32
00046 ::GetLocalTime(&m_time);
00047 #else
00048 gettimeofday(&m_tv, &m_tz);
00049 #endif
00050 }
00051
00052 private:
00053 Clock(const Clock& ) {}
00054 Clock& operator=(const Clock& ) { return *this; }
00055
00056 #ifdef _WIN32
00057 SYSTEMTIME m_time;
00058 SYSTEMTIME m_time0;
00059 #else
00060 struct timeval m_tv;
00061 struct timeval m_tv0;
00062 struct timezone m_tz;
00063 struct timezone m_tz0;
00064 #endif
00065 };
00066
00067
00068
00069
00070 #endif // _CLOCK_H