-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatistic.h
More file actions
49 lines (37 loc) · 784 Bytes
/
Statistic.h
File metadata and controls
49 lines (37 loc) · 784 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
46
47
48
49
#ifndef STATISTIC_H_
#define STATISTIC_H_
#include <deque>
#include <set>
class FPSStatistic
{
public:
double meanFPS;
double stddevFPS;
int numberOfFPS;
std::set<double> FPSs;
FPSStatistic() : meanFPS(0.0), stddevFPS(0.0), numberOfFPS(0) {
}
void update(int newFPS) {
FPSs.insert(newFPS);
}
void commit() {
std::deque<double> removal;
for (double fps : FPSs) {
removal.push_back(fps);
}
for (unsigned int i = 0; i < FPSs.size() * 0.15; ++i) {
removal.pop_front();
removal.pop_back();
}
for (double fps : removal) {
printf("%lf\n", fps);
meanFPS += fps;
stddevFPS += fps*fps;
}
meanFPS /= removal.size();
stddevFPS /= removal.size();
stddevFPS -= meanFPS*meanFPS;
stddevFPS = sqrt(stddevFPS);
}
};
#endif // STATISTIC_H_