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

Function calWriteAmp

libCacheSim/bin/dep/misc/flash.cpp:12–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#define MILLION 1000000ul
11
12void calWriteAmp(reader_t *reader, cache_t *cache) {
13 /* random seed */
14 srand(time(NULL));
15 set_rand_seed(rand());
16
17 request_t *req = new_request();
18 read_one_req(reader, req);
19 uint64_t start_ts = (uint64_t)req->clock_time;
20 req->clock_time = 0;
21
22 std::unordered_set<uint64_t> seen;
23
24 int64_t n_req = 0, n_byte = 0, n_uniq_obj = 0, n_uniq_byte = 0;
25 int64_t n_miss = 0, n_miss_byte = 0;
26 while (req->valid) {
27 n_req++;
28 n_byte += req->obj_size;
29 if (seen.find(req->obj_id) == seen.end()) {
30 seen.insert(req->obj_id);
31 n_uniq_obj++;
32 n_uniq_byte += req->obj_size;
33 }
34
35 if (cache->get(cache, req) == false) {
36 n_miss += 1;
37 n_miss_byte += req->obj_size;
38 }
39
40 read_one_req(reader, req);
41 req->clock_time -= start_ts;
42 }
43
44 // printf("%s %32s n_miss %.2lf Mobj (%.4lf, %.4lf), %.2lf MB (%.4lf, %.4lf)",
45 // basename(reader->trace_path), cache->cache_name,
46 // n_miss / (double)MILLION, n_miss / (double)n_req,
47 // n_miss / (double)n_uniq_obj, n_miss_byte / (double)MB,
48 // n_miss_byte / (double)n_byte, n_miss_byte / (double)n_uniq_byte);
49
50 printf("%s %32s miss ratio %.4lf %.4lf, ", basename(reader->trace_path),
51 cache->cache_name, n_miss / (double)n_req,
52 n_miss_byte / (double)n_byte);
53
54 int64_t n_byte_write = n_miss_byte;
55 if (strcasecmp("fifo", cache->cache_name) == 0) {
56 ;
57 } else if (strcasestr(cache->cache_name, "flashProb") != NULL) {
58 flashProb_params_t *params = (flashProb_params_t *)cache->eviction_params;
59
60 n_byte_write = params->n_byte_admit_to_disk;
61
62 if (strcasestr(params->disk->cache_name, "Clock") != NULL) {
63 Clock_params_t *clock_params =
64 (Clock_params_t *)params->disk->eviction_params;
65 n_byte_write += clock_params->n_byte_rewritten;
66 }
67 } else if (strcasestr(cache->cache_name, "clock") != NULL &&
68 strcasestr(cache->cache_name, "qdlp") == NULL) {
69 Clock_params_t *params = (Clock_params_t *)cache->eviction_params;

Callers 1

mainFunction · 0.70

Calls 7

new_requestFunction · 0.85
read_one_reqFunction · 0.85
set_rand_seedFunction · 0.50
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected