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

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