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

Function flashProb_parse_params

libCacheSim/cache/eviction/other/flashProb.c:362–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362static void flashProb_parse_params(cache_t *cache,
363 const char *cache_specific_params) {
364 flashProb_params_t *params = (flashProb_params_t *)(cache->eviction_params);
365
366 char *params_str = strdup(cache_specific_params);
367 char *old_params_str = params_str;
368
369 while (params_str != NULL && params_str[0] != '\0') {
370 /* different parameters are separated by comma,
371 * key and value are separated by = */
372 char *key = strsep((char **)&params_str, "=");
373 char *value = strsep((char **)&params_str, ",");
374
375 // skip the white space
376 while (params_str != NULL && *params_str == ' ') {
377 params_str++;
378 }
379
380 if (strcasecmp(key, "ram-size-ratio") == 0) {
381 params->ram_size_ratio = strtod(value, NULL);
382 } else if (strcasecmp(key, "disk-admit-prob") == 0) {
383 params->disk_admit_prob = strtod(value, NULL);
384 params->inv_prob = (int) (1.0 / params->disk_admit_prob);
385 } else if (strcasecmp(key, "ram-cache") == 0) {
386 strncpy(params->ram_cache_type, value, 15);
387 } else if (strcasecmp(key, "disk-cache") == 0) {
388 strncpy(params->disk_cache_type, value, 15);
389 } else if (strcasecmp(key, "print") == 0) {
390 printf("parameters: %s\n", flashProb_current_params(params));
391 exit(0);
392 } else {
393 ERROR("%s does not have parameter %s\n", cache->cache_name, key);
394 exit(1);
395 }
396 }
397
398 free(old_params_str);
399}
400
401#ifdef __cplusplus
402}

Callers 1

flashProb_initFunction · 0.85

Calls 1

flashProb_current_paramsFunction · 0.85

Tested by

no test coverage detected