Merge "Allow filtering and sorting by tag in benchmark result formatting" into main
This commit is contained in:
@@ -133,12 +133,16 @@ def format_duration_sec(ns):
|
|||||||
result += f"{m:2d}m "
|
result += f"{m:2d}m "
|
||||||
return result + f"{sec:2d}s"
|
return result + f"{sec:2d}s"
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog="format_benchmarks",
|
prog="format_benchmarks",
|
||||||
allow_abbrev=False, # Don't let people write unsupportable scripts.
|
allow_abbrev=False, # Don't let people write unsupportable scripts.
|
||||||
description="Print analysis tables for benchmarks")
|
description="Print analysis tables for benchmarks")
|
||||||
|
|
||||||
|
parser.add_argument("--tags", nargs="*",
|
||||||
|
help="The tags to print, in order.")
|
||||||
|
|
||||||
parser.add_argument("summaries", nargs="*",
|
parser.add_argument("summaries", nargs="*",
|
||||||
help="A summary.json file or a directory in which to look for summaries.")
|
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["datetime"] = dt
|
||||||
s["date"] = datetime.date(dt.year, dt.month, dt.day)
|
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
|
# 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
|
# group the benchmarks by column and iteration
|
||||||
def bm_key(b):
|
def bm_key(b):
|
||||||
|
Reference in New Issue
Block a user