Skip to content

Commit 8c0f681

Browse files
committed
fix: Add validation for heatmap data loading in trace analysis scripts
* Raise ValueError if no data is available for reuse and size heatmaps. * Ensure at least two objects are present for popularity data to prevent errors during analysis. * Adjusted rotation of x-ticks in reuse plot for better readability.
1 parent 4e050e5 commit 8c0f681

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

scripts/traceAnalysis/popularity.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ def load_popularity_data(datapath):
4343

4444
ifile.close()
4545

46+
if len(sorted_freq) < 2:
47+
raise ValueError(
48+
f"insufficient popularity data in {datapath} "
49+
"(need at least 2 objects, trace may have too few)"
50+
)
4651
return sorted_freq, freq_cnt
4752

4853

scripts/traceAnalysis/reuse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def plot_reuse(datapath: str, figname_prefix: str = "") -> None:
127127
plt.xticks(
128128
np.array([60, 300, 3600, 86400, 86400 * 2, 86400 * 4]) / 3600,
129129
["1 min", "5 min", "1 hour", "1 day", "", "4 day"],
130-
rotation=28,
130+
rotation=90,
131131
)
132132
plt.savefig(
133133
"{}/{}_reuse_rt_log.{}".format(FIG_DIR, figname_prefix, FIG_TYPE),

scripts/traceAnalysis/reuse_heatmap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ def _load_reuse_heatmap_data(datapath: str) -> Tuple[np.ndarray, int, int, float
9090

9191
ifile.close()
9292

93-
dim = max([len(l) for l in reuse_time_distribution_list])
93+
if not reuse_time_distribution_list:
94+
raise ValueError(
95+
f"no reuse heatmap data in {datapath} (trace may have time span 0)"
96+
)
97+
dim = max(len(l) for l in reuse_time_distribution_list)
9498
plot_data = np.ones((len(reuse_time_distribution_list), dim))
9599
for idx, l in enumerate(reuse_time_distribution_list):
96100
plot_data[idx][: len(l)] = np.cumsum(np.array(l) / sum(l))

scripts/traceAnalysis/size_heatmap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def _load_size_heatmap_data(datapath) -> Tuple[np.ndarray, int, float, int]:
6868

6969
ifile.close()
7070

71-
dim = max([len(l) for l in size_distribution_over_time])
71+
if not size_distribution_over_time:
72+
raise ValueError(
73+
f"no size heatmap data in {datapath} (trace may have time span 0)"
74+
)
75+
dim = max(len(l) for l in size_distribution_over_time)
7276
plot_data = np.zeros((len(size_distribution_over_time), dim))
7377

7478
for idx, l in enumerate(size_distribution_over_time):

0 commit comments

Comments
 (0)