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

Method gen_miss_trace

example/cacheHierarchy/simulator.cpp:14–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace std;
13
14double Simulator::gen_miss_trace(string algo, uint64_t cache_size,
15 string trace_path, string miss_output_path) {
16 uint64_t n_req = 0, n_hit = 0;
17 std::ofstream miss_ofs(miss_output_path);
18
19 reader_init_param_t reader_init_params = {
20 .time_field = 1, .obj_id_field = 2, .obj_size_field = 3, .next_access_vtime_field = 4};
21 // see the cacheSimulator example for using csv trace
22 reader_init_params.binary_fmt_str = "<IQIQ";
23 reader_t *reader =
24 open_trace(trace_path.c_str(), BIN_TRACE, &reader_init_params);
25 common_cache_params_t cc_params = {.cache_size = cache_size};
26 cache_t *cache = create_cache(algo.c_str(), cc_params, nullptr);
27
28 request_t *req = new_request();
29
30 bool hit;
31 read_one_req(reader, req);
32 while (req->valid) {
33 n_req += 1;
34 hit = cache->get(cache, req);
35 if (!hit)
36 miss_ofs << req->clock_time << "," << (uint64_t)req->obj_id << ","
37 << req->obj_size << std::endl;
38 else
39 n_hit += 1;
40 read_one_req(reader, req);
41 }
42
43 miss_ofs.close();
44 std::cout << trace_path << ", object miss ratio "
45 << 1.0 - (double)n_hit / n_req << std::endl;
46
47 return 1.0 - (double)n_hit / n_req;
48}
49
50void Simulator::output_mrc(string &algo, vector<uint64_t> cache_sizes,
51 string &trace_path, string &mrc_output_path) {

Callers

nothing calls this directly

Calls 5

open_traceFunction · 0.85
new_requestFunction · 0.85
read_one_reqFunction · 0.85
create_cacheFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected