-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathSimpleTimer.cpp
More file actions
44 lines (31 loc) · 791 Bytes
/
SimpleTimer.cpp
File metadata and controls
44 lines (31 loc) · 791 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
#include "SimpleTimer.h"
SimpleTimer::SimpleTimer()
{
}
SimpleTimer::~SimpleTimer()
{
}
void SimpleTimer::start()
{
start_time = GetTimeMs64();
}
float SimpleTimer::stop()
{
__int64 end_time = GetTimeMs64();
return ( float )( end_time - start_time );
}
__int64 SimpleTimer::GetTimeMs64()
{
/* Windows */
FILETIME ft;
LARGE_INTEGER li;
/* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and copy it
* to a LARGE_INTEGER structure. */
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
__int64 ret = li.QuadPart;
ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */
ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */
return ret;
}