From 2bc7a2fb4c9630224ef1f918fb3feca78fa7da4d Mon Sep 17 00:00:00 2001 From: Michael Oviedo Date: Fri, 15 Nov 2024 19:45:17 +0000 Subject: [PATCH] rename item_key to metric_field + adjust comment Signed-off-by: Michael Oviedo --- osbenchmark/aggregator.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/osbenchmark/aggregator.py b/osbenchmark/aggregator.py index 8199f875..d53409f5 100644 --- a/osbenchmark/aggregator.py +++ b/osbenchmark/aggregator.py @@ -199,18 +199,18 @@ def calculate_weighted_average(self, task_metrics: Dict[str, List[Any]], iterati for metric, values in task_metrics.items(): if isinstance(values[0], dict): weighted_metrics[metric] = {} - for item_key in values[0].keys(): - if item_key == 'unit': - weighted_metrics[metric][item_key] = values[0][item_key] - elif item_key == 'min': - weighted_metrics[metric]['overall_min'] = min(value.get(item_key, 0) for value in values) - elif item_key == 'max': - weighted_metrics[metric]['overall_max'] = max(value.get(item_key, 0) for value in values) + for metric_field in values[0].keys(): + if metric_field == 'unit': + weighted_metrics[metric][metric_field] = values[0][metric_field] + elif metric_field == 'min': + weighted_metrics[metric]['overall_min'] = min(value.get(metric_field, 0) for value in values) + elif metric_field == 'max': + weighted_metrics[metric]['overall_max'] = max(value.get(metric_field, 0) for value in values) else: - # for items like median or percentile values - item_values = [value.get(item_key, 0) for value in values] + # for items like median or containing percentile values + item_values = [value.get(metric_field, 0) for value in values] weighted_sum = sum(value * iterations for value in item_values) - weighted_metrics[metric][item_key] = weighted_sum / total_iterations + weighted_metrics[metric][metric_field] = weighted_sum / total_iterations else: weighted_sum = sum(value * iterations for value in values) weighted_metrics[metric] = weighted_sum / total_iterations