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

Function main

example/cacheSimulator/main.c:7–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include "libCacheSim.h"
6
7int main(int argc, char **argv) {
8 /* setup a csv reader */
9 reader_init_param_t init_params = default_reader_init_params();
10 init_params.obj_id_field = 5;
11 init_params.obj_size_field = 4;
12 init_params.time_field = 2;
13 init_params.has_header_set = true;
14 init_params.has_header = true;
15 init_params.delimiter = ',';
16
17 /* we can also use open_trace with the same parameters */
18 reader_t *reader =
19 open_trace("../../../data/cloudPhysicsIO.csv", CSV_TRACE, &init_params);
20
21 /* set up a request */
22 request_t *req = new_request();
23
24 /* read one request and print */
25 read_one_req(reader, req);
26 print_request(req);
27
28 /* setup a cache */
29 common_cache_params_t cc_params = {
30 .cache_size = 1 * GiB, .hashpower = 24, .consider_obj_metadata = false};
31 cache_t *lru = LRU_init(cc_params, NULL);
32
33 int64_t n_hit = 0, n_req = 0;
34 while (read_one_req(reader, req) == 0) {
35 if (lru->get(lru, req)) {
36 n_hit++;
37 }
38 n_req++;
39 }
40
41 printf("hit ratio: %lf\n", (double)n_hit / n_req);
42
43 free_request(req);
44 lru->cache_free(lru);
45 close_reader(reader);
46
47 return 0;
48}

Callers

nothing calls this directly

Calls 9

open_traceFunction · 0.85
new_requestFunction · 0.85
read_one_reqFunction · 0.85
print_requestFunction · 0.85
LRU_initFunction · 0.85
free_requestFunction · 0.85
close_readerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected