[go: up one dir, main page]

Menu

[r225]: / tags / 0.3.0 / watch.cpp  Maximize  Restore  History

Download this file

48 lines (39 with data), 761 Bytes

 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
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdlib.h>
#include "platform.h"
#include "watch.h"
Watch::Watch(void)
{
Reset();
}
void Watch::Start()
{
system_time(&_startTime);
_isRunning = true;
}
void Watch::Stop()
{
system_time(&_stopTime);
_isRunning = false;
}
void Watch::Reset()
{
_startTime = _stopTime;
_isRunning = false;
}
// Get elapsed time in millisec
uint64_t Watch::GetElapsedTime()
{
if(_isRunning)
{
sys_time_t now;
system_time(&now);
return time_to_msec(now)-time_to_msec(_startTime);
}
return time_to_msec(_stopTime)-time_to_msec(_startTime);
}
uint64_t Watch::GetRandomSeed()
{
sys_time_t now;
system_time(&now);
return time_to_msec(now);
}