MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / cal_one_hit

Function cal_one_hit

libCacheSim/bin/customized/SOSP23/oneHit/oneHit.cpp:21–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using namespace std;
20
21void cal_one_hit(reader_t *reader, char *ofilepath) {
22 unordered_map<uint64_t, uint32_t> freq_map;
23 vector<double> one_hit_ratio_vec;
24
25 request_t *req = new_request();
26
27 read_one_req(reader, req);
28 size_t last_size = 0;
29 uint64_t n_one_hit = 0;
30
31 while (req->valid) {
32 if (freq_map.find(req->obj_id) == freq_map.end()) {
33 freq_map[req->obj_id] = 1;
34 n_one_hit++;
35 } else {
36 freq_map[req->obj_id] += 1;
37 if (freq_map[req->obj_id] == 2) {
38 n_one_hit--;
39 }
40 }
41
42 if (freq_map.size() % 100 == 0 && freq_map.size() != last_size) {
43 one_hit_ratio_vec.push_back((double)n_one_hit / freq_map.size());
44 last_size = freq_map.size();
45
46 if (one_hit_ratio_vec.size() != freq_map.size() / 100) {
47 ERROR("Error: one_hit_ratio_vec.size() != freq_map.size() / 100\n");
48 }
49 }
50
51 read_one_req(reader, req);
52 }
53
54 ofstream ofile(ofilepath, ios::out);
55 ofile << reader->trace_path << ":";
56 for (auto ratio : one_hit_ratio_vec) {
57 ofile << ratio << ",";
58 }
59 ofile << endl;
60
61 ofile.close();
62
63 printf("%s in total %ld elem %ld objects %.4lf %.4lf\n", reader->trace_path,
64 one_hit_ratio_vec.size(), freq_map.size(), one_hit_ratio_vec[0],
65 one_hit_ratio_vec[one_hit_ratio_vec.size() - 1]);
66}

Callers 1

mainFunction · 0.70

Calls 5

new_requestFunction · 0.85
read_one_reqFunction · 0.85
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected