diff --git a/hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py b/hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py index 594a96b202e0526e3c3dae5263b195fc8db95a94..9b9011e6f6f405c9e1e92957754011aa80cbc72d 100644 --- a/hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py +++ b/hpvm/projects/hpvm-profiler/hpvm_profiler/__init__.py @@ -1,4 +1,3 @@ -from dataclasses import dataclass from pathlib import Path from subprocess import PIPE, CalledProcessError from typing import Iterable, List, Tuple, Union @@ -39,7 +38,12 @@ def profile_config_file( raise ValueError("Config file with no configs is unsupported.") # Modifies configs in place. profile_configs( - binary_path, configs[1:], configs[0], progress_bar, profile_filename, qos_filename + binary_path, + configs[1:], + configs[0], + progress_bar, + profile_filename, + qos_filename, ) write_hpvm_configs(header, configs, Path(output_config_path)) @@ -57,10 +61,10 @@ def profile_configs( from tqdm import tqdm - baseline_time, baseline_acc = profile_config(binary_path, baseline_config) + baseline_time, baseline_acc = measure_config(binary_path, baseline_config) iterable = tqdm(configs, desc="Configs profiled") if progress_bar else configs - for idx in iterable: - time, acc = profile_config(binary_path, config, profile_filename, qos_filename) + for config in iterable: + time, acc = measure_config(binary_path, config, profile_filename, qos_filename) speedup = baseline_time / time config.update_profile_results(speedup, acc, baseline_acc) return configs @@ -127,15 +131,23 @@ def plot_hpvm_configs( return fig -@dataclass class Config: - conf_name: str - speedup: float - energy: float - qos: float - qos_loss: float - # We don't care about the information in this part, and we don't parse this. - config_body: List[str] + def __init__( + self, + conf_name: str, + speedup: float, + energy: float, + qos: float, + qos_loss: float, + config_body: List[str], + ): + self.conf_name = conf_name + self.speedup = speedup + self.energy = energy + self.qos = qos + self.qos_loss = qos_loss + # We don't care about the information in this part, and we don't parse this. + self.config_body = config_body def update_profile_results(self, speedup: float, qos: float, base_qos: float): recorded_base_qos = self.qos + self.qos_loss @@ -189,7 +201,6 @@ def write_hpvm_configs(header: str, configs: Iterable[Config], to_file: PathLike f.flush() - def _read_profile_file(profile_file_path: Path): with profile_file_path.open() as f: target_lines = [line.strip() for line in f if "Total Time" in line]