* @brief parse the command line arguments * * @param argc * @param argv */
| 429 | * @param argv |
| 430 | */ |
| 431 | void parse_cmd(int argc, char *argv[], struct arguments *args) { |
| 432 | init_arg(args); |
| 433 | |
| 434 | static struct argp argp = {.options = options, |
| 435 | .parser = parse_opt, |
| 436 | .args_doc = args_doc, |
| 437 | .doc = doc, |
| 438 | .children = NULL, |
| 439 | .help_filter = NULL, |
| 440 | .argp_domain = NULL}; |
| 441 | |
| 442 | argp_parse(&argp, argc, argv, 0, 0, args); |
| 443 | |
| 444 | args->trace_path = args->args[0]; |
| 445 | const char *trace_type_str = args->args[1]; |
| 446 | |
| 447 | // initialize the trace reader |
| 448 | args->reader = |
| 449 | create_reader(trace_type_str, args->trace_path, args->trace_type_params, |
| 450 | args->n_req, args->ignore_obj_size, 1); |
| 451 | |
| 452 | // initialize the mrc profiler params |
| 453 | mrc_profiler_params_parse(args->cache_algorithm_str, args->mrc_profiler_str, |
| 454 | args->mrc_profiler_params_str, args->mrc_size_str, |
| 455 | args->mrc_profiler_type, args->mrc_profiler_params); |
| 456 | |
| 457 | if (args->mrc_profiler_params.profile_wss_ratio.size() != 0) { |
| 458 | // need calcuate the working set size |
| 459 | long wss = 0; |
| 460 | int64_t wss_obj = 0, wss_byte = 0; |
| 461 | cal_working_set_size(args->reader, &wss_obj, &wss_byte); |
| 462 | wss = wss_byte; |
| 463 | |
| 464 | for (size_t i = 0; i < args->mrc_profiler_params.profile_wss_ratio.size(); |
| 465 | i++) { |
| 466 | args->mrc_profiler_params.profile_size.push_back( |
| 467 | wss * args->mrc_profiler_params.profile_wss_ratio[i]); |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | void free_arg(struct arguments *args) { close_reader(args->reader); } |
| 473 |
no test coverage detected