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