@brief convert the cache size string to byte, * example input1: 1024,2048,4096,8192 * example input2: 1GB,2GB,4GB,8GB * example input3: 1024 * example input4: 0 * * @param cache_size_str * @param args * @return int */
| 437 | * @return int |
| 438 | */ |
| 439 | static int conv_cache_sizes(char *cache_size_str, struct arguments *args) { |
| 440 | char *token = strtok(cache_size_str, ","); |
| 441 | long wss = 0; |
| 442 | args->n_cache_size = 0; |
| 443 | while (token != NULL) { |
| 444 | if (strchr(token, '.') != NULL) { |
| 445 | // input is a float |
| 446 | if (wss == 0) { |
| 447 | int64_t wss_obj = 0, wss_byte = 0; |
| 448 | cal_working_set_size(args->reader, &wss_obj, &wss_byte); |
| 449 | wss = args->ignore_obj_size ? wss_obj : wss_byte; |
| 450 | } |
| 451 | args->cache_sizes[args->n_cache_size++] = (uint64_t)(wss * atof(token)); |
| 452 | } else { |
| 453 | args->cache_sizes[args->n_cache_size++] = conv_size_str_to_byte_ul(token); |
| 454 | } |
| 455 | |
| 456 | token = strtok(NULL, ","); |
| 457 | } |
| 458 | |
| 459 | if (args->n_cache_size == 1 && args->cache_sizes[0] == 0) { |
| 460 | set_cache_size(args, args->reader); |
| 461 | } |
| 462 | |
| 463 | return args->n_cache_size; |
| 464 | } |
| 465 | |
| 466 | static void set_cache_size(struct arguments *args, reader_t *reader) { |
| 467 | #define N_AUTO_CACHE_SIZE 8 |
no test coverage detected