21 #ifndef UPRECISION_TIMER_H
22 #define UPRECISION_TIMER_H
25 #ifndef WIN32_LEAN_AND_MEAN
26 #define WIN32_LEAN_AND_MEAN
30 namespace OpenSkyNet {
32 class PrecisionTimer {
33 LARGE_INTEGER _freq, _begin, _end, _stamp;
35 PrecisionTimer() { QueryPerformanceFrequency(&_freq); }
37 inline void start() { QueryPerformanceCounter(&_begin); }
39 inline double stop() {
40 QueryPerformanceCounter(&_end);
42 return (static_cast<double>(_end.QuadPart - _begin.QuadPart) / _freq.QuadPart);
45 inline double stamp() {
46 QueryPerformanceCounter(&_stamp);
48 return (static_cast<double>(_stamp.QuadPart) / _freq.QuadPart);
56 namespace OpenSkyNet {
59 timeval _begin, _end, _stamp;
61 inline void start() { gettimeofday(&_begin, 0); }
64 gettimeofday(&_end, 0);
66 double t1 =
static_cast<double>(_begin.tv_sec +
static_cast<double>(_begin.tv_usec)/(1000000));
67 double t2 =
static_cast<double>(_end.tv_sec +
static_cast<double>(_end.tv_usec)/(1000000));
72 gettimeofday(&_stamp, 0);
74 return static_cast<double>(_stamp.tv_sec +
static_cast<double>(_stamp.tv_usec)/(1000000));
81 #endif //UPRECISION_TIMER_H
void start()
Definition: UPrecisionTimer.h:61
double stop()
Definition: UPrecisionTimer.h:63
double stamp()
Definition: UPrecisionTimer.h:71
Definition: UPrecisionTimer.h:58