forked from goossaert/hashmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitoring.h
125 lines (97 loc) · 3.08 KB
/
monitoring.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef HASHMAP_MONITORING
#define HASHMAP_MONITORING
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <string>
#include <iostream>
#include <map>
#include <vector>
namespace hashmap
{
class HashMap;
class Monitoring
{
public:
Monitoring(uint64_t num_buckets,
uint64_t max_num_items_in_bucket,
HashMap *hm) {
num_buckets_ = num_buckets;
max_num_items_in_bucket_ = max_num_items_in_bucket;
size_bucket_ = 4;
hm_ = hm;
fprintf(stderr, "starting\n");
}
virtual ~Monitoring() {
}
uint64_t** GetClustering(HashMap* hm);
void PrintClustering(HashMap *hm);
const std::map<uint64_t, uint64_t>& GetClustering();
uint64_t GetDIB(uint64_t index);
void SetDIB(uint64_t index, uint64_t dib);
void RemoveDIB(uint64_t index);
void PrintDIB(std::string filepath);
void AddDFB(uint64_t distance);
void ResetDFB();
void PrintDFB(std::string filepath);
void AddAlignedDFB(uint64_t index_init, uint64_t index_free_bucket);
void ResetAlignedDFB();
void PrintAlignedDFB(std::string filepath);
void AddDMB(uint64_t distance);
void ResetDMB();
void PrintDMB(std::string filepath);
void AddAlignedDMB(uint64_t index_init, uint64_t index_free_bucket);
void ResetAlignedDMB();
void PrintAlignedDMB(std::string filepath);
void AddNumberOfSwaps(uint64_t distance);
void ResetNumberOfSwaps();
void PrintNumberOfSwaps(std::string filepath);
void GetNumScannedBlocks(std::map<uint64_t, uint64_t>& out_num_scanned_blocks, HashMap *hm);
void PrintNumScannedBlocks(std::string filepath);
void AddDSB(uint64_t distance);
void ResetDSB();
void PrintDSB(std::string filepath);
void AddAlignedDSB(uint64_t index_stored, uint64_t index_shift_bucket);
void ResetAlignedDSB();
void PrintAlignedDSB(std::string filepath);
void PrintInfo(FILE* fd, std::string metric);
void SetCycle(uint64_t cycle) { cycle_ = cycle; }
void SetInstance(uint64_t instance) { instance_ = instance; }
void SetTestcase(std::string str) {
testcase_ = str;
}
void SetParametersTestcaseString(std::string str) {
parameters_testcase_string_ = str;
}
void SetParametersTestcaseJson(std::string str) {
parameters_testcase_json_ = str;
}
private:
std::map<uint64_t, uint64_t> num_items_in_bucket_;
uint64_t num_buckets_;
uint64_t max_num_items_in_bucket_;
uint64_t size_bucket_;
std::map<uint64_t, uint64_t> dib_;
std::map<uint64_t, uint64_t> dfb_;
std::map<uint64_t, uint64_t> aligned_dfb_;
std::map<uint64_t, uint64_t> dmb_;
std::map<uint64_t, uint64_t> aligned_dmb_;
std::map<uint64_t, uint64_t> dsb_;
std::map<uint64_t, uint64_t> aligned_dsb_;
std::map<uint64_t, uint64_t> swaps_;
HashMap *hm_;
uint64_t cycle_;
uint64_t instance_;
std::string parameters_testcase_string_;
std::string parameters_testcase_json_;
std::string testcase_;
uint64_t AlignOffsetToBlock(uint64_t offset, uint64_t size_block) {
return offset - offset % size_block;
}
};
}; // end namespace hashmap
#endif // HASHMAP_MONITORING