Skip to content

Commit

Permalink
Unify result print format to be ignore-obj-size-aware (#66)
Browse files Browse the repository at this point in the history
* Unify result print format

* Unify cache size str in traceAnalyzer
  • Loading branch information
haochengxia authored Jun 19, 2024
1 parent 9d0e80d commit 3abee5f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libCacheSim/bin/cachesim/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void parse_cmd(int argc, char *argv[], struct arguments *args);
void free_arg(struct arguments *args);

void simulate(reader_t *reader, cache_t *cache, int report_interval,
int warmup_sec, char *ofilepath);
int warmup_sec, char *ofilepath, bool ignore_obj_size);

void print_parsed_args(struct arguments *args);

Expand Down
4 changes: 3 additions & 1 deletion libCacheSim/bin/cachesim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, char **argv) {

if (args.n_cache_size * args.n_eviction_algo == 1) {
simulate(args.reader, args.caches[0], args.report_interval, args.warmup_sec,
args.ofilepath);
args.ofilepath, args.ignore_obj_size);

free_arg(&args);
return 0;
Expand Down Expand Up @@ -54,6 +54,8 @@ int main(int argc, char **argv) {
} else if (args.cache_sizes[0] > KiB) {
size_unit = KiB;
size_unit_str = "KiB";
} else {
size_unit_str = "B";
}
}

Expand Down
26 changes: 18 additions & 8 deletions libCacheSim/bin/cachesim/sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
#endif

void simulate(reader_t *reader, cache_t *cache, int report_interval,
int warmup_sec, char *ofilepath) {
int warmup_sec, char *ofilepath, bool ignore_obj_size) {
/* random seed */
srand(time(NULL));
set_rand_seed(rand());
Expand Down Expand Up @@ -66,15 +66,25 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval,

char output_str[1024];
char size_str[8];
convert_size_to_str(cache->cache_size, size_str);
if (!ignore_obj_size)
convert_size_to_str(cache->cache_size, size_str);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
snprintf(output_str, 1024,
"%s %s cache size %8s, %16lu req, miss ratio %.4lf, throughput "
"%.2lf MQPS\n",
reader->trace_path, cache->cache_name, size_str,
(unsigned long)req_cnt, (double)miss_cnt / (double)req_cnt,
(double)req_cnt / 1000000.0 / runtime);
if (!ignore_obj_size) {
snprintf(output_str, 1024,
"%s %s cache size %8s, %16lu req, miss ratio %.4lf, throughput "
"%.2lf MQPS\n",
reader->trace_path, cache->cache_name, size_str,
(unsigned long)req_cnt, (double)miss_cnt / (double)req_cnt,
(double)req_cnt / 1000000.0 / runtime);
} else {
snprintf(output_str, 1024,
"%s %s cache size %8ld, %16lu req, miss ratio %.4lf, throughput "
"%.2lf MQPS\n",
reader->trace_path, cache->cache_name, cache->cache_size,
(unsigned long)req_cnt, (double)miss_cnt / (double)req_cnt,
(double)req_cnt / 1000000.0 / runtime);
}

#pragma GCC diagnostic pop
printf("%s", output_str);
Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/traceAnalyzer/utils/include/utilsStr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static inline void convert_size_to_str(long long size, char *str) {
} else if (size >= KiB) {
sprintf(str, "%.0lf KiB", (double) size / KiB);
} else {
sprintf(str, "%lld", size);
sprintf(str, "%lld B", size);
}
}

Expand Down
2 changes: 1 addition & 1 deletion libCacheSim/utils/mystr.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void convert_size_to_str(unsigned long long size, char *str) {
} else if (size >= KiB) {
sprintf(str, "%.0lfKiB", (double)size / KiB);
} else {
sprintf(str, "%lld", size);
sprintf(str, "%lldB", size);
}
}

Expand Down

0 comments on commit 3abee5f

Please sign in to comment.