diff options
Diffstat (limited to 'scripts/buildstats-diff')
-rwxr-xr-x | scripts/buildstats-diff | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff index c9aa76a8fa..df1df432f1 100755 --- a/scripts/buildstats-diff +++ b/scripts/buildstats-diff | |||
@@ -12,6 +12,7 @@ import glob | |||
12 | import logging | 12 | import logging |
13 | import math | 13 | import math |
14 | import os | 14 | import os |
15 | import pathlib | ||
15 | import sys | 16 | import sys |
16 | from operator import attrgetter | 17 | from operator import attrgetter |
17 | 18 | ||
@@ -251,11 +252,32 @@ Script for comparing buildstats of two separate builds.""" | |||
251 | "average over them") | 252 | "average over them") |
252 | parser.add_argument('--only-task', dest='only_tasks', metavar='TASK', action='append', default=[], | 253 | parser.add_argument('--only-task', dest='only_tasks', metavar='TASK', action='append', default=[], |
253 | help="Only include TASK in report. May be specified multiple times") | 254 | help="Only include TASK in report. May be specified multiple times") |
254 | parser.add_argument('buildstats1', metavar='BUILDSTATS1', help="'Left' buildstat") | 255 | parser.add_argument('buildstats1', metavar='BUILDSTATS1', nargs="?", help="'Left' buildstat") |
255 | parser.add_argument('buildstats2', metavar='BUILDSTATS2', help="'Right' buildstat") | 256 | parser.add_argument('buildstats2', metavar='BUILDSTATS2', nargs="?", help="'Right' buildstat") |
256 | 257 | ||
257 | args = parser.parse_args(argv) | 258 | args = parser.parse_args(argv) |
258 | 259 | ||
260 | if args.buildstats1 and args.buildstats2: | ||
261 | # Both paths specified | ||
262 | pass | ||
263 | elif args.buildstats1 or args.buildstats2: | ||
264 | # Just one path specified, this is an error | ||
265 | parser.print_usage(sys.stderr) | ||
266 | print("Either specify two buildstats paths, or none to use the last two paths.", file=sys.stderr) | ||
267 | sys.exit(1) | ||
268 | else: | ||
269 | # No paths specified, try to find the last two buildstats | ||
270 | try: | ||
271 | buildstats_dir = pathlib.Path(os.environ["BUILDDIR"]) / "tmp" / "buildstats" | ||
272 | paths = sorted(buildstats_dir.iterdir()) | ||
273 | args.buildstats2 = paths.pop() | ||
274 | args.buildstats1 = paths.pop() | ||
275 | print(f"Comparing {args.buildstats1} -> {args.buildstats2}\n") | ||
276 | except KeyError: | ||
277 | parser.print_usage(sys.stderr) | ||
278 | print("Build environment has not been configured, cannot find buildstats", file=sys.stderr) | ||
279 | sys.exit(1) | ||
280 | |||
259 | # We do not nedd/want to read all buildstats if we just want to look at the | 281 | # We do not nedd/want to read all buildstats if we just want to look at the |
260 | # package versions | 282 | # package versions |
261 | if args.ver_diff: | 283 | if args.ver_diff: |