13
0

and one more gettimeofday() transition (mackie timers)

This commit is contained in:
Robin Gareus 2014-05-16 18:35:42 +02:00
parent 030a8f189d
commit 5fba8a2015

View File

@ -50,17 +50,8 @@ public:
*/ */
unsigned long start() unsigned long start()
{ {
#ifdef _WIN32 _start = g_get_monotonic_time();
_start = (unsigned long)::GetTickCount(); return _start / 1000;
#else
gettimeofday ( &_start, 0 );
#endif
running = true;
#ifdef _WIN32
return _start;
#else
return ( _start.tv_sec * 1000000 + _start.tv_usec ) / 1000;
#endif
} }
/** /**
@ -69,12 +60,7 @@ public:
*/ */
unsigned long stop() unsigned long stop()
{ {
#ifdef _WIN32 _stop = g_get_monotonic_time();
_stop = (unsigned long)::GetTickCount();
#else
gettimeofday ( &_stop, 0 );
#endif
running = false;
return elapsed(); return elapsed();
} }
@ -85,28 +71,12 @@ public:
{ {
if ( running ) if ( running )
{ {
#ifdef _WIN32 uint64_t now = g_get_monotonic_time();
DWORD current = ::GetTickCount(); return (now - _start) / 1000;
return current - _start;
#else
struct timeval current;
gettimeofday ( &current, 0 );
return (
( current.tv_sec * 1000000 + current.tv_usec ) - ( _start.tv_sec * 1000000 + _start.tv_usec )
) / 1000
;
#endif
} }
else else
{ {
#ifdef _WIN32 return (_stop - _start) / 1000;
return _stop - _start;
#else
return (
( _stop.tv_sec * 1000000 + _stop.tv_usec ) - ( _start.tv_sec * 1000000 + _start.tv_usec )
) / 1000
;
#endif
} }
} }
@ -121,13 +91,8 @@ public:
} }
private: private:
#ifdef _WIN32 uint64_t _start;
unsigned long _start; uint64_t _stop;
unsigned long _stop;
#else
struct timeval _start;
struct timeval _stop;
#endif
bool running; bool running;
}; };