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

Function plot_mrc_time

scripts/plot_mrc_time.py:107–153  ·  view source on GitHub ↗

plot the miss ratio from the computation X-axis is time, different lines are different algos Args: mrc_dict: a dict of mrc, key is the algo name, value is (time_list, miss_ratio_list) name: the name of the plot, default: mrc Returns: None

(
    mrc_dict: Dict[str, Tuple[List[float], List[float]]], 
    name: str = "mrc"
)

Source from the content-addressed store, hash-verified

105
106
107def plot_mrc_time(
108 mrc_dict: Dict[str, Tuple[List[float], List[float]]],
109 name: str = "mrc"
110) -> None:
111 """plot the miss ratio from the computation
112 X-axis is time, different lines are different algos
113 Args:
114 mrc_dict: a dict of mrc, key is the algo name, value is (time_list, miss_ratio_list)
115 name: the name of the plot, default: mrc
116 Returns:
117 None
118 """
119
120 linestyles = itertools.cycle(["-", "--", "-.", ":"])
121 linestyles = itertools.cycle(["--", "-", "--", "-.", ":"])
122 colors = itertools.cycle(
123 [
124 "navy",
125 "darkorange",
126 "tab:green",
127 "cornflowerblue",
128 ]
129 )
130 MARKERS = itertools.cycle(Line2D.markers.keys())
131
132 for algo, (ts, mrc) in mrc_dict.items():
133 ts = np.array(ts) / ts[-1]
134 plt.plot(
135 ts,
136 mrc,
137 linewidth=4,
138 color=next(colors),
139 linestyle=next(linestyles),
140 label=algo,
141 )
142
143 plt.xlabel("Time")
144 plt.ylabel("Miss Ratio")
145 legend = plt.legend(ncol=2, loc="upper left", frameon=False)
146 frame = legend.get_frame()
147 frame.set_facecolor("0.9")
148 frame.set_edgecolor("0.9")
149 plt.grid(axis="y", linestyle="--")
150 plt.savefig("{}.pdf".format(name), bbox_inches="tight")
151 plt.show()
152 plt.clf()
153 print("plot is saved to {}.pdf".format(name))
154
155
156def run():

Callers 2

runFunction · 0.85
plot_mrc_time.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected