-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimer.h
44 lines (42 loc) · 943 Bytes
/
Timer.h
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
#pragma once
#include <vector>
struct time
{
int hours = 0;
int minutes = 0;
int seconds = 0;
int milliseconds = 0;
time operator+(time rhs)
{
this->hours += rhs.hours;
this->minutes += rhs.minutes;
this->seconds += rhs.seconds;
this->milliseconds += rhs.milliseconds;
return (*this);
}
time operator/(int factor)
{
this->hours = this->hours/factor;
this->minutes = this->minutes / factor;
this->seconds = this->seconds / factor;
this->milliseconds = this->milliseconds / factor;
return (*this);
}
};
class TimerFunc {
public:
TimerFunc();
~TimerFunc();
void startTimer();
void stopTimer();
private:
time times;
time calculateTimeAverage(std::vector<time> times);
LARGE_INTEGER frequency; // ticks per second
LARGE_INTEGER t1, t2; // ticks
double elapsedTime;
std::vector<time> Timesnth;
std::vector<time> Timesqs;
std::vector<time> Timesrand;
std::vector<time> Timesmedian;
};