blob: bfd23c091645c0627fe638479686c3455f0af4d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "TimeHelpers.h"
#include <unistd.h>
namespace UnitTest {
Timer::Timer()
{
m_startTime.tv_sec = 0;
m_startTime.tv_usec = 0;
}
void Timer::Start()
{
gettimeofday(&m_startTime, 0);
}
int Timer::GetTimeInMs() const
{
struct timeval currentTime;
gettimeofday(¤tTime, 0);
int const dsecs = currentTime.tv_sec - m_startTime.tv_sec;
int const dus = currentTime.tv_usec - m_startTime.tv_usec;
return dsecs*1000 + dus/1000;
}
void TimeHelpers::SleepMs (int ms)
{
usleep(ms * 1000);
}
}
|