From 8911d4407333ba297ad66d2f12eae1547e6d9dff Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 13 Nov 2024 15:21:35 -0600 Subject: [PATCH] scripts: csv.py: Fixed field defines hiding field renames The issue here is quite nuanced, but becomes a problem when you want to both: 1. Filter results by a given field: -Dmeas=write 2. Output a new value for that field: -bmeas='"write+amor"' If you didn't guess from the example, this comes up often in scripts dealing with bench results, where we often find ourselves wanting to append/merge modified results based on the raw measurements. Fortunately the fix is relatively easy: We already filter by defines in our collect function, so we don't really need to filter by defines again when folding. Folding occurs after expr evaluation, but collect occurs before, so this limits filtering to the input fields _before_ expr evaluation. This does mean we no longer filter on the output of exprs, but I don't know if such behavior was ever intentionally desired. Worst case it can be emulated by stacking multiple csv.py calls, which may be annoying, but is at least well-intentioned and well-defined. --- Note that the other result scripts, code.py, stack.py, etc, are a bit different in that they rely on fold-time filtering for filtering generated results. This may deserve a refactor at some point, but since these scripts don't also evaluate exprs, it's not an immediate problem. --- scripts/csv.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/csv.py b/scripts/csv.py index 17cb3bf2..b5242a71 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -1600,7 +1600,7 @@ def main(csv_paths, *, results = results_ # fold - results = fold(Result, results, by=by, defines=defines) + results = fold(Result, results, by=by) # sort, note that python's sort is stable results.sort() @@ -1640,7 +1640,7 @@ def main(csv_paths, *, diff_results = diff_results_ # fold - diff_results = fold(Result, diff_results, by=by, defines=defines) + diff_results = fold(Result, diff_results, by=by) # print table if not args.get('quiet'):