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

Method add_req

libCacheSim/traceAnalyzer/reuse.cpp:17–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using namespace std;
16
17void ReuseDistribution::add_req(request_t *req) {
18 if (unlikely(next_window_ts_ == -1)) {
19 next_window_ts_ = (int64_t)req->clock_time + time_window_;
20 }
21
22 if (req->rtime_since_last_access < 0) {
23 // compulsory miss
24 reuse_rtime_req_cnt_[-1] += 1;
25 reuse_vtime_req_cnt_[-1] += 1;
26
27 return;
28 }
29
30 int pos_rt = (int)(req->rtime_since_last_access / rtime_granularity_);
31 int pos_vt = (int)(log(double(req->vtime_since_last_access)) / log_log_base_);
32
33 reuse_rtime_req_cnt_[pos_rt] += 1;
34 reuse_vtime_req_cnt_[pos_vt] += 1;
35
36 // switch (req->op) {
37 // case OP_GET:
38 // case OP_GETS:
39 // reuse_rtime_req_cnt_read_[pos_rt] += 1;
40 // break;
41 // case OP_SET:
42 // case OP_ADD:
43 // case OP_REPLACE:
44 // case OP_CAS:
45 // reuse_rtime_req_cnt_write_[pos_rt] += 1;
46 // break;
47 // case OP_DELETE:
48 // reuse_rtime_req_cnt_delete_[pos_rt] += 1;
49 // break;
50 // default:
51 // break;
52 // }
53
54 if (time_window_ <= 0) return;
55
56 utils::vector_incr(window_reuse_rtime_req_cnt_, pos_rt, (uint32_t)1);
57 utils::vector_incr(window_reuse_vtime_req_cnt_, pos_vt, (uint32_t)1);
58
59 while (req->clock_time >= next_window_ts_) {
60 stream_dump_window_reuse_distribution();
61 window_reuse_rtime_req_cnt_.clear();
62 window_reuse_vtime_req_cnt_.clear();
63 next_window_ts_ += time_window_;
64 }
65}
66
67void ReuseDistribution::dump(string &path_base) {
68 ofstream ofs(path_base + ".reuse", ios::out | ios::trunc);

Callers

nothing calls this directly

Calls 3

logFunction · 0.85
vector_incrFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected