| 5 | #include "libCacheSim.h" |
| 6 | |
| 7 | int 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 | } |
nothing calls this directly
no test coverage detected