From 67c944b351413ab9ef20417155835a590a01d2fc Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Thu, 21 Dec 2023 13:29:18 -0800 Subject: [PATCH] Allow filtering and sorting by tag in benchmark result formatting Test: build/make/tools/perf/format_benchmarks --tags n2d-standard-128 n2-standard-80 n2d-standard-48 Change-Id: Ie4a4e36d4bc2aab50a017acbaf3ef0e23ddae958 --- tools/perf/format_benchmarks | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/perf/format_benchmarks b/tools/perf/format_benchmarks index 4c1e38b879..c01aa76214 100755 --- a/tools/perf/format_benchmarks +++ b/tools/perf/format_benchmarks @@ -133,12 +133,16 @@ def format_duration_sec(ns): result += f"{m:2d}m " return result + f"{sec:2d}s" + def main(argv): parser = argparse.ArgumentParser( prog="format_benchmarks", allow_abbrev=False, # Don't let people write unsupportable scripts. description="Print analysis tables for benchmarks") + parser.add_argument("--tags", nargs="*", + help="The tags to print, in order.") + parser.add_argument("summaries", nargs="*", help="A summary.json file or a directory in which to look for summaries.") @@ -154,8 +158,18 @@ def main(argv): s["datetime"] = dt s["date"] = datetime.date(dt.year, dt.month, dt.day) + # Filter out tags we don't want + if args.tags: + summaries = [(f, s) for f, s in summaries if s.get("tag", "") in args.tags] + + # If they supplied tags, sort in that order, otherwise sort by tag + if args.tags: + tagsort = lambda tag: args.tags.index(tag) + else: + tagsort = lambda tag: tag + # Sort the summaries - summaries.sort(key=lambda s: (s[1]["date"], s[1]["branch"], s[1]["tag"])) + summaries.sort(key=lambda s: (s[1]["date"], s[1]["branch"], tagsort(s[1]["tag"]))) # group the benchmarks by column and iteration def bm_key(b):