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