MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / ClockPro_parse_params

Function ClockPro_parse_params

libCacheSim/cache/eviction/ClockPro.c:483–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483static 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 **)&params_str, "=");
491 char *value = strsep((char **)&params_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}

Callers 1

ClockPro_initFunction · 0.85

Calls 1

ClockPro_current_paramsFunction · 0.85

Tested by

no test coverage detected