| 481 | } |
| 482 | |
| 483 | static void ClockPro_parse_params(cache_t *cache, const char *cache_specific_params) { |
| 484 | ClockPro_params_t *params = (ClockPro_params_t *)(cache->eviction_params); |
| 485 | char *params_str = strdup(cache_specific_params); |
| 486 | char *old_params_str = params_str; |
| 487 | char *end; |
| 488 | |
| 489 | while (params_str != NULL && params_str[0] != '\0') { |
| 490 | char *key = strsep((char **)¶ms_str, "="); |
| 491 | char *value = strsep((char **)¶ms_str, ","); |
| 492 | |
| 493 | while (params_str != NULL && *params_str == ' ') { |
| 494 | params_str++; |
| 495 | } |
| 496 | |
| 497 | if (strcasecmp(key, "init-ref") == 0) { |
| 498 | params->init_ref = strtol(value, &end, 10); |
| 499 | } else if (strcasecmp(key, "init-ratio-cold") == 0) { |
| 500 | const double ratio = strtod(value, &end); |
| 501 | params->mem_cold_max = (int64_t)((double)cache->cache_size * ratio); |
| 502 | } else if (strcasecmp(key, "print") == 0) { |
| 503 | printf("current parameters: %s\n", ClockPro_current_params(cache, params)); |
| 504 | exit(0); |
| 505 | } else { |
| 506 | ERROR("%s does not have parameter %s\n", cache->cache_name, key); |
| 507 | } |
| 508 | } |
| 509 | free(old_params_str); |
| 510 | } |
| 511 | |
| 512 | #ifdef __cplusplus |
| 513 | } |
no test coverage detected