From 175db8403765a114fa36c061bd0cab0a3da22ffb Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 30 Oct 2024 17:42:20 +0100 Subject: [PATCH] bench/parameter: Adding get_name_with_position() This function is an helper to provide a unique name to benchmarks. The current job position is padded to the current job name. This commit: - add this new function - replace the existing occurences. - change the output to report the name with position at runtime Before : [full_cpu_load] stressng/cpu/matrixprod(M): 1 stressor on CPU [0] for 60s [full_cpu_load] stressng/cpu/matrixprod(M): 2 stressor on CPU [0] for 60s [full_cpu_load] stressng/cpu/matrixprod(M): 4 stressor on CPU [0] for 60s After: [full_cpu_load_0] stressng/cpu/matrixprod(M): 1 stressor on CPU [0] for 60s [full_cpu_load_1] stressng/cpu/matrixprod(M): 2 stressor on CPU [0] for 60s [full_cpu_load_2] stressng/cpu/matrixprod(M): 4 stressor on CPU [0] for 60s Signed-off-by: Erwan Velu --- hwbench/bench/benchmark.py | 2 +- hwbench/bench/benchmarks.py | 10 ++++------ hwbench/bench/parameters.py | 5 +++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hwbench/bench/benchmark.py b/hwbench/bench/benchmark.py index 64dd8ad..87f78ef 100644 --- a/hwbench/bench/benchmark.py +++ b/hwbench/bench/benchmark.py @@ -140,7 +140,7 @@ def pre_run(self): monitoring = "(M)" print( "[{}] {}/{}/{}{}: {:3d} stressor{} for {}s{}".format( - p.get_name(), + p.get_name_with_position(), self.engine_module.get_engine().get_name(), self.engine_module.get_name(), p.get_engine_module_parameter(), diff --git a/hwbench/bench/benchmarks.py b/hwbench/bench/benchmarks.py index 4e6194f..67560a6 100644 --- a/hwbench/bench/benchmarks.py +++ b/hwbench/bench/benchmarks.py @@ -265,11 +265,9 @@ def run(self): ) # Save each benchmark result - results[ - "{}_{}".format( - benchmark.get_parameters().get_name(), benchmark.get_job_number() - ) - ] = benchmark.run() + results[benchmark.get_parameters().get_name_with_position()] = ( + benchmark.run() + ) return results def dump(self): @@ -278,7 +276,7 @@ def dump(self): engine = bench.get_enginemodule().get_engine() em = bench.get_enginemodule() param = bench.get_parameters() - print(f"[{param.get_name()}_{bench.get_job_number()}]", file=f) + print(f"[{param.get_name_with_position()}]", file=f) print(f"runtime={param.get_runtime()}", file=f) print(f"monitoring={param.get_monitoring_config()}", file=f) print(f"engine={engine.get_name()}", file=f) diff --git a/hwbench/bench/parameters.py b/hwbench/bench/parameters.py index 84a33e7..64073f4 100644 --- a/hwbench/bench/parameters.py +++ b/hwbench/bench/parameters.py @@ -50,6 +50,11 @@ def get_pinned_cpu(self): def get_name(self) -> str: return self.job_name + def get_name_with_position(self) -> str: + if not self.benchmark: + return self.get_name() + return f"{self.get_name()}_{self.benchmark.get_job_number()}" + def get_engine_instances_count(self) -> int: return self.engine_instances