From 7212c5d4def1ca05acf7be3a33436517200b8e25 Mon Sep 17 00:00:00 2001 From: lixiang_yewu Date: Mon, 8 Jan 2024 01:15:59 +0000 Subject: [PATCH] update src/benchService.py. Signed-off-by: lixiang_yewu --- src/benchService.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/benchService.py b/src/benchService.py index 28a0d85..6656e15 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 -- Gitee