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

Function export_histogram_to_csv

libCacheSim/dataStructure/histogram.c:57–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57void export_histogram_to_csv(ReuseHistogram* hist, float rate, char* path) {
58 printf("Histogram path: %s\n", path);
59
60 FILE* file = fopen(path, "w");
61 if (!file) return;
62
63 fprintf(file, "Distance,Frequency\n");
64
65 if (hist->cold_miss_bin > 0) {
66 fprintf(file, "ColdMiss,%lu\n", hist->cold_miss_bin);
67 }
68
69 GHashTableIter iter;
70 gpointer key, value;
71 g_hash_table_iter_init(&iter, hist->bins);
72 while (g_hash_table_iter_next(&iter, &key, &value)) {
73 uint64_t distance = *(uint64_t*)key;
74 BinEntry* bin = (BinEntry*)value;
75 double scaled_distance = (double)(distance) / (double)rate;
76
77 if (scaled_distance > (double)UINT64_MAX) {
78 fprintf(file, "Overflow,%lu\n", bin->frequency);
79 } else {
80 fprintf(file, "%lu,%lu\n", (uint64_t)scaled_distance, bin->frequency);
81 }
82 }
83
84 fclose(file);
85}
86
87uint64_t get_min_distance(ReuseHistogram* hist) {
88 if (!hist || g_hash_table_size(hist->bins) == 0) {

Callers 1

generate_shards_mrcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected