Revision 706, 0.5 kB
(checked in by smidl, 15 years ago)
|
eol-native
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | #include "TimeHelpers.h" |
---|
2 | #include <unistd.h> |
---|
3 | |
---|
4 | namespace UnitTest { |
---|
5 | |
---|
6 | Timer::Timer() { |
---|
7 | m_startTime.tv_sec = 0; |
---|
8 | m_startTime.tv_usec = 0; |
---|
9 | } |
---|
10 | |
---|
11 | void Timer::Start() { |
---|
12 | gettimeofday ( &m_startTime, 0 ); |
---|
13 | } |
---|
14 | |
---|
15 | double Timer::GetTimeInMs() const { |
---|
16 | struct timeval currentTime; |
---|
17 | gettimeofday ( ¤tTime, 0 ); |
---|
18 | |
---|
19 | double const dsecs = currentTime.tv_sec - m_startTime.tv_sec; |
---|
20 | double const dus = currentTime.tv_usec - m_startTime.tv_usec; |
---|
21 | |
---|
22 | return ( dsecs * 1000.0 ) + ( dus / 1000.0 ); |
---|
23 | } |
---|
24 | |
---|
25 | void TimeHelpers::SleepMs ( int ms ) { |
---|
26 | usleep ( ms * 1000 ); |
---|
27 | } |
---|
28 | |
---|
29 | } |
---|