Skip to content

Commit

Permalink
rename item_key to metric_field + adjust comment
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Oviedo <[email protected]>
  • Loading branch information
OVI3D0 committed Nov 15, 2024
1 parent 16d3428 commit 2bc7a2f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions osbenchmark/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bc7a2f

Please sign in to comment.