fix: skip non-metrics in benchmark output

Fixes #468
This commit is contained in:
Philipp Emanuel Weidmann
2026-10-07 18:07:26 +05:30
parent fd7c77e5c3
commit 449b351735
+29 -28
View File
@@ -1327,6 +1327,15 @@ def run():
else: else:
table.add_column("Value", justify="right") table.add_column("Value", justify="right")
def format_value(value: Any) -> str:
if isinstance(
value,
(float, np.floating),
):
return f"{value:.4f}"
else:
return f"{value}"
try: try:
first_benchmark = True first_benchmark = True
@@ -1350,37 +1359,29 @@ def run():
first_row = True first_row = True
for metric, value in results.items(): for metric, value in results.items():
if metric != "alias": # Skip non-metrics.
if first_row and not first_benchmark: if metric in ["name", "alias", "sample_len"]:
if benchmark_original_model: continue
table.add_row("", "", "", "")
else:
table.add_row("", "", "")
def format_value(value: Any) -> str: if first_row and not first_benchmark:
if isinstance(
value,
(float, np.floating),
):
return f"{value:.4f}"
else:
return f"{value}"
cells = [
benchmark.name if first_row else "",
metric,
format_value(value),
]
if benchmark_original_model: if benchmark_original_model:
cells.append( table.add_row("", "", "", "")
format_value( else:
original_results[metric] table.add_row("", "", "")
)
)
table.add_row(*cells)
first_row = False cells = [
first_benchmark = False benchmark.name if first_row else "",
metric,
format_value(value),
]
if benchmark_original_model:
cells.append(
format_value(original_results[metric])
)
table.add_row(*cells)
first_row = False
first_benchmark = False
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass