-
Notifications
You must be signed in to change notification settings - Fork 5
/
Stats.h
65 lines (46 loc) · 1.33 KB
/
Stats.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef STATS_H_
#define STATS_H_
#include <vector>
#include <chrono>
using namespace std;
typedef struct Stat {
unsigned long operation_num;
unsigned int add_op_in_window;
unsigned int rem_op_in_window;
double micros;
double last_triangles_est;
unsigned long long last_triangles_count;
unsigned int last_size_sample;
double micros_per_op;
unsigned int last_timestamp;
unsigned int op_count_total;
} Stat;
class Stats {
public:
explicit Stats(const int stat_window_size) :
stat_window_size_(stat_window_size), op_count_(0) {
add_count_window_ = remove_count_window_ = 0;
last_triangles_est_ = last_triangles_count_ = last_size_sample_ = 0;
last_op_count_ = 0;
}
virtual ~Stats();
void exec_op(bool is_add, unsigned long long last_triangles_count, double last_triangles_est, unsigned int last_size_sample, unsigned int timestamp);
void end_op();
const vector<Stat> stats() {
return stats_;
}
private:
void reset_window();
const unsigned int stat_window_size_;
unsigned int add_count_window_;
unsigned int remove_count_window_;
unsigned int last_size_sample_;
double last_triangles_est_;
unsigned long long last_triangles_count_;
unsigned int last_op_count_;
unsigned int last_timestamp_;
std::chrono::system_clock::time_point last_time_;
unsigned int op_count_;
vector<Stat> stats_;
};
#endif /* STATS_H_ */