comparison ext/UnitTest++/src/Posix/TimeHelpers.cpp @ 37:0d325e9d5953

added unittest++ files into ext. Not hooked into build scripts yet
author jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 12 Jul 2008 12:00:57 +0000
parents
children
comparison
equal deleted inserted replaced
36:6f1227f4932b 37:0d325e9d5953
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
18 int Timer::GetTimeInMs() const
19 {
20 struct timeval currentTime;
21 gettimeofday(&currentTime, 0);
22 int const dsecs = currentTime.tv_sec - m_startTime.tv_sec;
23 int const dus = currentTime.tv_usec - m_startTime.tv_usec;
24 return dsecs*1000 + dus/1000;
25 }
26
27
28 void TimeHelpers::SleepMs (int ms)
29 {
30 usleep(ms * 1000);
31 }
32
33 }