* @brief parse the command line arguments * * @param argc * @param argv */
| 272 | * @param argv |
| 273 | */ |
| 274 | void parse_cmd(int argc, char *argv[], struct arguments *args) { |
| 275 | init_arg(args); |
| 276 | |
| 277 | static struct argp argp = {.options = options, |
| 278 | .parser = parse_opt, |
| 279 | .args_doc = args_doc, |
| 280 | .doc = doc, |
| 281 | .children = NULL, |
| 282 | .help_filter = NULL, |
| 283 | .argp_domain = NULL}; |
| 284 | |
| 285 | argp_parse(&argp, argc, argv, 0, 0, args); |
| 286 | |
| 287 | args->trace_path = args->args[0]; |
| 288 | args->trace_type_str = args->args[1]; |
| 289 | parse_eviction_algo(args, args->args[2]); |
| 290 | |
| 291 | /* the third parameter is the cache size, but we cannot parse it now |
| 292 | * because we allow user to specify the cache size as fraction of the |
| 293 | * working set size, and the working set size can only be calculated |
| 294 | * after we set up the reader */ |
| 295 | assert(N_ARGS == 4); |
| 296 | |
| 297 | if (args->ofilepath[0] == '\0') { |
| 298 | char *trace_filename = rindex(args->trace_path, '/'); |
| 299 | snprintf(args->ofilepath, OFILEPATH_LEN, "result/%s.cachesim", |
| 300 | trace_filename == NULL ? args->trace_path : trace_filename + 1); |
| 301 | } |
| 302 | |
| 303 | /* convert trace type string to enum */ |
| 304 | args->trace_type = |
| 305 | trace_type_str_to_enum(args->trace_type_str, args->trace_path); |
| 306 | |
| 307 | reader_init_param_t reader_init_params; |
| 308 | memset(&reader_init_params, 0, sizeof(reader_init_params)); |
| 309 | reader_init_params.ignore_obj_size = args->ignore_obj_size; |
| 310 | reader_init_params.ignore_size_zero_req = true; |
| 311 | reader_init_params.obj_id_is_num = true; |
| 312 | reader_init_params.cap_at_n_req = args->n_req; |
| 313 | reader_init_params.sampler = NULL; |
| 314 | |
| 315 | parse_reader_params(args->trace_type_params, &reader_init_params); |
| 316 | |
| 317 | if (args->sample_ratio > 0 && args->sample_ratio < 1 - 1e-6) { |
| 318 | sampler_t *sampler = create_spatial_sampler(args->sample_ratio); |
| 319 | reader_init_params.sampler = sampler; |
| 320 | } |
| 321 | |
| 322 | if ((args->trace_type == CSV_TRACE || args->trace_type == PLAIN_TXT_TRACE) && |
| 323 | reader_init_params.obj_size_field == -1) { |
| 324 | args->consider_obj_metadata = false; |
| 325 | args->ignore_obj_size = true; |
| 326 | reader_init_params.ignore_obj_size = true; |
| 327 | } |
| 328 | |
| 329 | args->reader = |
| 330 | setup_reader(args->trace_path, args->trace_type, &reader_init_params); |
| 331 |
no test coverage detected