diff --git a/src/benchService.py b/src/benchService.py index 28a0d8509ee8f15b0c6a4a5c04f0f1be4a658d13..6656e15aeda616b8403b7c6796c651d7fb3dc0a0 100644 --- a/src/benchService.py +++ b/src/benchService.py @@ -15,12 +15,46 @@ class BenchmarkService: self.ALL = 'all' def output_bench_info(self, bench_case): + """ + Output benchmark information for a specific benchmark case. + + Parameters: + - bench_case (str): The benchmark case to output information for. + """ bench_path = os.path.join(self.ROOT, 'benchmark') - file_list = [d for d in glob(bench_path+'/**', recursive=False)] + file_list = [d for d in glob(os.path.join(bench_path, '**'), recursive=False)] + for file in file_list: cur_bench_case = os.path.basename(file) run_file = os.path.join(file, self.RUN_FILE) + if os.path.isdir(file) and os.path.exists(run_file): - cmd = f"cd {file} && chmod +x {self.RUN_FILE} && ./{self.RUN_FILE}" + self.set_execute_permissions(run_file) + if cur_bench_case == self.ALL or cur_bench_case == bench_case: - self.exe.exec_raw(cmd) + self.execute_benchmark(file) + + def set_execute_permissions(self, file_path): + """ + Set execute permissions for a file. + + Parameters: + - file_path (str): The path of the file for which execute permissions should be set. + """ + try: + os.chmod(file_path, 0o755) + except OSError as e: + print(f"Error setting execute permissions for {file_path}: {e}") + + def execute_benchmark(self, folder_path): + """ + Execute the benchmark located in the specified folder. + + Parameters: + - folder_path (str): The path of the folder containing the benchmark. + """ + try: + cmd = f"cd {folder_path} && ./{self.RUN_FILE}" + self.exe.exec_raw(cmd) + except Exception as e: + print(f"Error executing benchmark in {folder_path}: {e}") \ No newline at end of file