-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClock.cpp
41 lines (35 loc) · 1.03 KB
/
Clock.cpp
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
#include "Clock.h"
#include "utillity.h"
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#include <cstring>
namespace df {
Clock::Clock() {
m_previous_time = getCurrentTime();
}
//Computes elapsed time in microseconds and sets m_previous_time to the current time
long int Clock::delta() {
long int elapsedTime= getCurrentTime() - m_previous_time;
m_previous_time = getCurrentTime();
return elapsedTime;
}
//Computes elapsed time in microseconds
long int Clock::split(){
return getCurrentTime() - m_previous_time;
}
//Returns the m_previous_time variable
long int Clock::getPreviousTime() {
return m_previous_time;
}
//Computes current time in microseconds
long int Clock::getCurrentTime() {
SYSTEMTIME currentTime;
GetSystemTime(¤tTime);
return (currentTime.wDay * 24 * 60 * 60 * 1000000)
+ (currentTime.wHour * 60 * 60 * 1000000)
+ (currentTime.wMinute * 60 * 1000000)
+ (currentTime.wSecond * 1000000)
+ (currentTime.wMilliseconds * 1000);
}
}