()
| 160 | print("Integrated MINI plot saved to", plot_path) |
| 161 | |
| 162 | def main(): |
| 163 | parser = argparse.ArgumentParser( |
| 164 | description="Run the MRC binary to generate CSV outputs and then plot the MRC curve." |
| 165 | ) |
| 166 | subparsers = parser.add_subparsers(dest="algorithm", required=True, |
| 167 | help="Algorithm type: SHARDS or MINI") |
| 168 | |
| 169 | # SHARDS subparser: |
| 170 | shards_parser = subparsers.add_parser("SHARDS", help="Run SHARDS simulation") |
| 171 | shards_parser.add_argument("trace_file", help="Full path to the trace file") |
| 172 | shards_parser.add_argument("trace_type", help="Trace type (e.g., vscsi, csv, etc.)") |
| 173 | shards_parser.add_argument("rate", help="Sampling rate(s), comma-separated if multiple (e.g., 0.1,0.02)") |
| 174 | shards_parser.add_argument("--size", type=int, help="(Optional) Size for fixed-size mode (SHARDS only)") |
| 175 | shards_parser.add_argument("--extra_args", nargs=argparse.REMAINDER, |
| 176 | help="Additional arguments for the MRC binary") |
| 177 | |
| 178 | # MINI subparser: |
| 179 | mini_parser = subparsers.add_parser("MINI", help="Run MINI simulation") |
| 180 | mini_parser.add_argument("trace_file", help="Full path to the trace file") |
| 181 | mini_parser.add_argument("trace_type", help="Trace type (e.g., vscsi, csv, etc.)") |
| 182 | mini_parser.add_argument("eviction_algo", help="Eviction algorithm (e.g., lru)") |
| 183 | mini_parser.add_argument("cache_sizes", help="Cache sizes. In multi-rate mode, provide comma-separated sizes that match number of rates.") |
| 184 | mini_parser.add_argument("rate", help="Sampling rate(s). In multi-rate mode, comma-separated (e.g., 0.1,0.2)") |
| 185 | mini_parser.add_argument("--multirate", action="store_true", |
| 186 | help="Enable multi-rate mode for MINI") |
| 187 | mini_parser.add_argument("--extra_args", nargs=argparse.REMAINDER, |
| 188 | help="Additional arguments for the MRC binary") |
| 189 | |
| 190 | # Common arguments |
| 191 | parser.add_argument("--binary", default=DEFAULT_BINARY, |
| 192 | help="Path to the MRC binary") |
| 193 | parser.add_argument("--plot_path", default=DEFAULT_PLOT_PATH, |
| 194 | help="File path where the output plot image will be saved") |
| 195 | args = parser.parse_args() |
| 196 | |
| 197 | |
| 198 | out_files = [] # list to store generated CSV filenames |
| 199 | |
| 200 | if args.algorithm == "SHARDS": |
| 201 | histogram_dir = "../histograms" |
| 202 | os.makedirs(histogram_dir, exist_ok=True) |
| 203 | rates = [r.strip() for r in args.rate.split(",")] |
| 204 | for rate in rates: |
| 205 | output_csv = os.path.join(SHARDS_OUT_DIR, f"histogram_{rate}.csv") |
| 206 | cmd = [args.binary, "SHARDS", output_csv, args.trace_file, args.trace_type, rate] |
| 207 | if args.size is not None: |
| 208 | cmd.extend(["--size", str(args.size)]) |
| 209 | if args.extra_args: |
| 210 | cmd.extend(" ".join(args.extra_args).split()) |
| 211 | print("Running SHARDS simulation for rate", rate) |
| 212 | run_mrc_binary(args.binary, cmd) |
| 213 | out_files.append(output_csv) |
| 214 | plot_shards_multirate(out_files, args.plot_path) |
| 215 | else: # MINI |
| 216 | histogram_dir = "../histograms-mini" |
| 217 | os.makedirs(histogram_dir, exist_ok=True) |
| 218 | if args.multirate: |
| 219 | rate_list = [r.strip() for r in args.rate.split(",")] |
no test coverage detected