scripts: Adopted -c/--compare in make summary-diff

This showcases the sort of high-level result printing where -c/--compare
is useful:

  $ make summary-diff
              code             data           stack          structs
  BEFORE     57057                0            3056             1476
  AFTER      68864 (+20.7%)       0 (+0.0%)    3744 (+22.5%)    1520 (+3.0%)

There was one hiccup though: how to hide the name of the first field.

It may seem minor, but the missing field name really does help
readability when you're staring at a wall of CLI output.

It's a bit of a hack, but this can now be controlled with -Y/--summary,
which has the sole purpose of disabling the first field name if mixed
with -c/--compare.

-c/--compare is already a weird case for the summary row anyways...
This commit is contained in:
Christopher Haster
2024-11-14 13:15:25 -06:00
parent 29eff6f3e8
commit 9a2b561a76
9 changed files with 45 additions and 42 deletions

View File

@@ -537,7 +537,7 @@ def table(Result, results, diff_results=None, *,
return entry
# entries
if not summary:
if not summary or compare:
for name in names:
r = table.get(name)
if diff_results is None:
@@ -547,7 +547,7 @@ def table(Result, results, diff_results=None, *,
lines.append(table_entry(name, r, diff_r))
# total, unless we're comparing
if summary or not (compare is not None and diff_results is None):
if not (compare is not None and diff_results is None):
r = next(iter(fold(Result, results, by=[])), None)
if diff_results is None:
diff_r = None