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

@@ -344,13 +344,13 @@ summary sizes: \
$(BUILDDIR)/lfs.structs.csv
$(strip ./scripts/csv.py \
<(./scripts/csv.py $(BUILDDIR)/lfs.code.csv \
-fcode=size -q $(SUMMARYFLAGS) -o-) \
-fcode=size -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.data.csv \
-fdata=size -q $(SUMMARYFLAGS) -o-) \
-fdata=size -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.stack.csv \
-fstack='max(limit)' -q $(SUMMARYFLAGS) -o-) \
-fstack='max(limit)' -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.structs.csv \
-fstructs=size -q $(SUMMARYFLAGS) -o-) \
-fstructs=size -q -o-) \
-bfunction -fcode -fdata -fstack='max(stack)' -fstructs \
-Y $(SUMMARYFLAGS))
@@ -359,30 +359,33 @@ summary sizes: \
summary-diff sizes-diff: SHELL=/bin/bash
summary-diff sizes-diff: $(OBJ) $(CI)
$(strip ./scripts/csv.py \
<(./scripts/csv.py \
<(./scripts/csv.py \
<(./scripts/code.py $(OBJ) -q $(CODEFLAGS) -o-) \
-fcode=size -q $(SUMMARYFLAGS) -o-) \
-fcode=size -q -o-) \
<(./scripts/csv.py \
<(./scripts/data.py $(OBJ) -q $(DATAFLAGS) -o-) \
-fdata=size -q $(SUMMARYFLAGS) -o-) \
-fdata=size -q -o-) \
<(./scripts/csv.py \
<(./scripts/stack.py $(CI) -q $(STACKFLAGS) -o-) \
-fstack='max(limit)' -q $(SUMMARYFLAGS) -o-) \
-fstack='max(limit)' -q -o-) \
<(./scripts/csv.py \
<(./scripts/structs.py $(OBJ) -q $(STRUCTSFLAGS) -o-) \
-fstructs=size -q $(SUMMARYFLAGS) -o-) \
-bfunction -fcode -fdata -fstack='max(stack)' -fstructs \
-Y -p $(SUMMARYFLAGS) -d <(./scripts/csv.py \
<(./scripts/csv.py $(BUILDDIR)/lfs.code.csv \
-fcode=size -q $(SUMMARYFLAGS) -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.data.csv \
-fdata=size -q $(SUMMARYFLAGS) -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.stack.csv \
-fstack='max(limit)' -q $(SUMMARYFLAGS) -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.structs.csv \
-fstructs=size -q $(SUMMARYFLAGS) -o-) \
-fstructs=size -q -o-) \
-fcode -fdata -fstack='max(stack)' -fstructs \
-q $(SUMMARYFLAGS) -o-))
-bbuild='"AFTER"' -q -o-) \
<(./scripts/csv.py \
<(./scripts/csv.py $(BUILDDIR)/lfs.code.csv \
-fcode=size -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.data.csv \
-fdata=size -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.stack.csv \
-fstack='max(limit)' -q -o-) \
<(./scripts/csv.py $(BUILDDIR)/lfs.structs.csv \
-fstructs=size -q -o-) \
-fcode -fdata -fstack='max(stack)' -fstructs \
-bbuild='"BEFORE"' -q -o-) \
-bbuild -cBEFORE -Y $(SUMMARYFLAGS))
## Build the test-runner
.PHONY: test-runner build-tests

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

View File

@@ -547,7 +547,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:
@@ -557,7 +557,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

View File

@@ -1572,7 +1572,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:
@@ -1582,7 +1582,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

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

View File

@@ -936,7 +936,7 @@ def table(Result, results, diff_results=None, *,
prefixes[2+is_last] + " "))
# entries
if not summary:
if not summary or compare:
for name in names:
r = table.get(name)
if diff_results is None:
@@ -956,7 +956,7 @@ def table(Result, results, diff_results=None, *,
" "))
# 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

View File

@@ -900,7 +900,7 @@ def table(Result, results, diff_results=None, *,
prefixes[2+is_last] + " "))
# entries
if not summary:
if not summary or compare:
for name in names:
r = table.get(name)
if diff_results is None:
@@ -920,7 +920,7 @@ def table(Result, results, diff_results=None, *,
" "))
# 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

View File

@@ -582,7 +582,7 @@ def table(Result, results, diff_results=None, *,
prefixes[2+is_last] + " "))
# entries
if not summary:
if not summary or compare:
for name in names:
r = table.get(name)
if diff_results is None:
@@ -602,7 +602,7 @@ def table(Result, results, diff_results=None, *,
" "))
# 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

View File

@@ -487,7 +487,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:
@@ -497,7 +497,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