root/library/tests/unittest-cpp/Posix/TimeHelpers.cpp @ 446

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
4namespace UnitTest {
5
6Timer::Timer()
7{
8    m_startTime.tv_sec = 0;
9    m_startTime.tv_usec = 0;
10}
11
12void Timer::Start()
13{
14    gettimeofday(&m_startTime, 0);
15}
16
17double Timer::GetTimeInMs() const
18{
19    struct timeval currentTime;
20    gettimeofday(&currentTime, 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
28void TimeHelpers::SleepMs(int ms)
29{
30    usleep(ms * 1000);
31}
32
33}
Note: See TracBrowser for help on using the browser.