plot the miss ratio from the computation X-axis is cache size, different lines are different algos Args: mrc_dict: a dict of mrc, key is the algo name, value is a list of (cache_size, miss_ratio) cache_size_has_unit: whether the cache size has unit, default: False
(
mrc_dict: Dict[str, List[Tuple[int, float]]],
cache_size_has_unit: bool = False,
use_byte_miss_ratio: bool = False,
name: str = "mrc",
)
| 121 | |
| 122 | |
| 123 | def plot_mrc_size( |
| 124 | mrc_dict: Dict[str, List[Tuple[int, float]]], |
| 125 | cache_size_has_unit: bool = False, |
| 126 | use_byte_miss_ratio: bool = False, |
| 127 | name: str = "mrc", |
| 128 | ) -> None: |
| 129 | """plot the miss ratio from the computation |
| 130 | X-axis is cache size, different lines are different algos |
| 131 | |
| 132 | Args: |
| 133 | mrc_dict: a dict of mrc, key is the algo name, value is a list of (cache_size, miss_ratio) |
| 134 | cache_size_has_unit: whether the cache size has unit, default: False |
| 135 | use_byte_miss_ratio: whether to plot the miss ratio in byte, default: False |
| 136 | name: the name of the plot, default: mrc |
| 137 | Returns: |
| 138 | None |
| 139 | |
| 140 | """ |
| 141 | |
| 142 | linestyles = itertools.cycle(["-", "--", "-.", ":"]) |
| 143 | markers = itertools.cycle( |
| 144 | [ |
| 145 | "o", |
| 146 | "v", |
| 147 | "^", |
| 148 | "<", |
| 149 | ">", |
| 150 | "s", |
| 151 | "p", |
| 152 | "P", |
| 153 | "*", |
| 154 | "h", |
| 155 | "H", |
| 156 | "+", |
| 157 | "x", |
| 158 | "X", |
| 159 | "D", |
| 160 | "d", |
| 161 | "|", |
| 162 | "_", |
| 163 | ] |
| 164 | ) |
| 165 | # MARKERS = itertools.cycle(Line2D.markers.keys()) |
| 166 | # colors = itertools.cycle(["r", "g", "b", "c", "m", "y", "k"]) |
| 167 | |
| 168 | first_size = int(list(mrc_dict.values())[0][0][0]) |
| 169 | if cache_size_has_unit: |
| 170 | size_unit, size_unit_str = find_unit_of_cache_size(first_size) |
| 171 | else: |
| 172 | size_unit, size_unit_str = 1, "" |
| 173 | |
| 174 | for algo, mrc in mrc_dict.items(): |
| 175 | logger.debug(mrc) |
| 176 | |
| 177 | miss_ratio = [x[1] for x in mrc] |
| 178 | byte_miss_ratio = [x[2] for x in mrc] |
| 179 | plt.plot( |
| 180 | [x[0] / size_unit for x in mrc], |
no test coverage detected