-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimer.cpp
45 lines (40 loc) · 1.25 KB
/
Timer.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
42
43
44
45
#include "Timer.hpp"
#include <time.h>
#include <vector>
using namespace std;
void addTime(string name, clock_t t, vector<Timer> ×){
if (times.size() > 0){
Timer test = times.back();
times.push_back(Timer(name,t,times.back().retTime()));
} else {
times.push_back(Timer(name,t,0));
}
}
void totalTime(vector<Timer> ×, bool includeInit){
if (includeInit){
times.push_back(Timer("Total Time",times.back().retTime(),times.front().retTime()));
} else {
times.push_back(Timer("Total Time without Init",times.back().retTime(),times[2].retTime()));
}
}
void printTimes(vector<Timer> ×, int start, int end){
for(int i = start; i < end; i++){
times[i].print();
}
}
vector<Timer> averageArray(vector<vector<Timer>> &tests){
int testLen = tests[0].size();
vector<float> testTimes(testLen,0);
for (int i = 0; i < tests.size(); i++){
for (int j = 0; j < testLen; j++){
testTimes[j] += tests[i][j].mseconds;
}
}
vector<Timer> average = {};
for (int j = 0; j < testLen; j++){
string name = tests[0][j].name;
float aveTime = testTimes[j]/tests.size();
average.push_back(Timer(name, aveTime));
}
return average;
}