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

Function plot_reuse

scripts/traceAnalysis/reuse.py:94–160  ·  view source on GitHub ↗

plot reuse time distribution Args: datapath (str): the path of reuse data file figname_prefix (str, optional): the prefix of figname. Defaults to "". Returns: None: None

(datapath: str, figname_prefix: str = "")

Source from the content-addressed store, hash-verified

92
93
94def plot_reuse(datapath: str, figname_prefix: str = "") -> None:
95 """
96 plot reuse time distribution
97
98 Args:
99 datapath (str): the path of reuse data file
100 figname_prefix (str, optional): the prefix of figname. Defaults to "".
101
102 Returns:
103 None: None
104
105 """
106
107 if not figname_prefix:
108 figname_prefix = extract_dataname(datapath)
109
110 reuse_rtime_count, reuse_vtime_count = _load_reuse_data(datapath, False)
111
112 x, y = conv_to_cdf(None, data_dict=reuse_rtime_count)
113 if x[0] < 0:
114 # this is compulsory miss
115 x = x[1:]
116 y = [y[i] - y[0] for i in range(1, len(y))]
117 plt.plot([i / 3600 for i in x], y)
118 plt.grid(linestyle="--")
119 # plt.ylim(0, 1)
120 plt.xlabel("Time (Hour)")
121 plt.ylabel("Fraction of requests (CDF)")
122 plt.savefig(
123 "{}/{}_reuse_rt.{}".format(FIG_DIR, figname_prefix, FIG_TYPE),
124 bbox_inches="tight",
125 )
126 plt.xscale("log")
127 plt.xticks(
128 np.array([60, 300, 3600, 86400, 86400 * 2, 86400 * 4]) / 3600,
129 ["1 min", "5 min", "1 hour", "1 day", "", "4 day"],
130 rotation=28,
131 )
132 plt.savefig(
133 "{}/{}_reuse_rt_log.{}".format(FIG_DIR, figname_prefix, FIG_TYPE),
134 bbox_inches="tight",
135 )
136 plt.clf()
137
138 x, y = conv_to_cdf(None, data_dict=reuse_vtime_count)
139 if x[0] < 0:
140 x = x[1:]
141 y = [y[i] - y[0] for i in range(1, len(y))]
142 plt.plot([i for i in x], y)
143 plt.grid(linestyle="--")
144 plt.xlabel("Virtual time (# requests)")
145 plt.ylabel("Fraction of requests (CDF)")
146 plt.savefig(
147 "{}/{}_reuse_vt.{}".format(FIG_DIR, figname_prefix, FIG_TYPE),
148 bbox_inches="tight",
149 )
150 plt.xscale("log")
151 plt.savefig(

Callers 1

reuse.pyFile · 0.85

Calls 3

extract_datanameFunction · 0.90
conv_to_cdfFunction · 0.90
_load_reuse_dataFunction · 0.85

Tested by

no test coverage detected