diff options
-rwxr-xr-x | scripts/buildstats-diff | 14 | ||||
-rw-r--r-- | scripts/lib/buildstats.py | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/scripts/buildstats-diff b/scripts/buildstats-diff index c179c93528..2f6498ab67 100755 --- a/scripts/buildstats-diff +++ b/scripts/buildstats-diff | |||
@@ -114,7 +114,7 @@ def print_ver_diff(bs1, bs2): | |||
114 | print(fmt_str.format(name, field1, field2, maxlen=maxlen)) | 114 | print(fmt_str.format(name, field1, field2, maxlen=maxlen)) |
115 | 115 | ||
116 | 116 | ||
117 | def print_task_diff(bs1, bs2, val_type, min_val=0, min_absdiff=0, sort_by=('absdiff',)): | 117 | def print_task_diff(bs1, bs2, val_type, min_val=0, min_absdiff=0, sort_by=('absdiff',), only_tasks=[]): |
118 | """Diff task execution times""" | 118 | """Diff task execution times""" |
119 | def val_to_str(val, human_readable=False): | 119 | def val_to_str(val, human_readable=False): |
120 | """Convert raw value to printable string""" | 120 | """Convert raw value to printable string""" |
@@ -151,8 +151,9 @@ def print_task_diff(bs1, bs2, val_type, min_val=0, min_absdiff=0, sort_by=('absd | |||
151 | """Get cumulative sum of all tasks""" | 151 | """Get cumulative sum of all tasks""" |
152 | total = 0.0 | 152 | total = 0.0 |
153 | for recipe_data in buildstats.values(): | 153 | for recipe_data in buildstats.values(): |
154 | for bs_task in recipe_data.tasks.values(): | 154 | for name, bs_task in recipe_data.tasks.items(): |
155 | total += getattr(bs_task, val_type) | 155 | if not only_tasks or name in only_tasks: |
156 | total += getattr(bs_task, val_type) | ||
156 | return total | 157 | return total |
157 | 158 | ||
158 | if min_val: | 159 | if min_val: |
@@ -163,7 +164,7 @@ def print_task_diff(bs1, bs2, val_type, min_val=0, min_absdiff=0, sort_by=('absd | |||
163 | val_to_str(min_absdiff, True), val_to_str(min_absdiff))) | 164 | val_to_str(min_absdiff, True), val_to_str(min_absdiff))) |
164 | 165 | ||
165 | # Prepare the data | 166 | # Prepare the data |
166 | tasks_diff = diff_buildstats(bs1, bs2, val_type, min_val, min_absdiff) | 167 | tasks_diff = diff_buildstats(bs1, bs2, val_type, min_val, min_absdiff, only_tasks) |
167 | 168 | ||
168 | # Sort our list | 169 | # Sort our list |
169 | for field in reversed(sort_by): | 170 | for field in reversed(sort_by): |
@@ -248,6 +249,8 @@ Script for comparing buildstats of two separate builds.""" | |||
248 | parser.add_argument('--multi', action='store_true', | 249 | parser.add_argument('--multi', action='store_true', |
249 | help="Read all buildstats from the given paths and " | 250 | help="Read all buildstats from the given paths and " |
250 | "average over them") | 251 | "average over them") |
252 | 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") | ||
251 | parser.add_argument('buildstats1', metavar='BUILDSTATS1', help="'Left' buildstat") | 254 | parser.add_argument('buildstats1', metavar='BUILDSTATS1', help="'Left' buildstat") |
252 | parser.add_argument('buildstats2', metavar='BUILDSTATS2', help="'Right' buildstat") | 255 | parser.add_argument('buildstats2', metavar='BUILDSTATS2', help="'Right' buildstat") |
253 | 256 | ||
@@ -266,7 +269,6 @@ Script for comparing buildstats of two separate builds.""" | |||
266 | 269 | ||
267 | return args | 270 | return args |
268 | 271 | ||
269 | |||
270 | def main(argv=None): | 272 | def main(argv=None): |
271 | """Script entry point""" | 273 | """Script entry point""" |
272 | args = parse_args(argv) | 274 | args = parse_args(argv) |
@@ -290,7 +292,7 @@ def main(argv=None): | |||
290 | print_ver_diff(bs1, bs2) | 292 | print_ver_diff(bs1, bs2) |
291 | else: | 293 | else: |
292 | print_task_diff(bs1, bs2, args.diff_attr, args.min_val, | 294 | print_task_diff(bs1, bs2, args.diff_attr, args.min_val, |
293 | args.min_absdiff, sort_by) | 295 | args.min_absdiff, sort_by, args.only_tasks) |
294 | except ScriptError as err: | 296 | except ScriptError as err: |
295 | log.error(str(err)) | 297 | log.error(str(err)) |
296 | return 1 | 298 | return 1 |
diff --git a/scripts/lib/buildstats.py b/scripts/lib/buildstats.py index 1adab06edf..c69b5bf4d7 100644 --- a/scripts/lib/buildstats.py +++ b/scripts/lib/buildstats.py | |||
@@ -261,13 +261,17 @@ class BuildStats(dict): | |||
261 | self[pkg].aggregate(data) | 261 | self[pkg].aggregate(data) |
262 | 262 | ||
263 | 263 | ||
264 | def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None): | 264 | def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None, only_tasks=[]): |
265 | """Compare the tasks of two buildstats""" | 265 | """Compare the tasks of two buildstats""" |
266 | tasks_diff = [] | 266 | tasks_diff = [] |
267 | pkgs = set(bs1.keys()).union(set(bs2.keys())) | 267 | pkgs = set(bs1.keys()).union(set(bs2.keys())) |
268 | for pkg in pkgs: | 268 | for pkg in pkgs: |
269 | tasks1 = bs1[pkg].tasks if pkg in bs1 else {} | 269 | tasks1 = bs1[pkg].tasks if pkg in bs1 else {} |
270 | tasks2 = bs2[pkg].tasks if pkg in bs2 else {} | 270 | tasks2 = bs2[pkg].tasks if pkg in bs2 else {} |
271 | if only_tasks: | ||
272 | tasks1 = {k: v for k, v in tasks1.items() if k in only_tasks} | ||
273 | tasks2 = {k: v for k, v in tasks2.items() if k in only_tasks} | ||
274 | |||
271 | if not tasks1: | 275 | if not tasks1: |
272 | pkg_op = '+' | 276 | pkg_op = '+' |
273 | elif not tasks2: | 277 | elif not tasks2: |