scripts/buildstats-diff: Add option to filter tasks

Adds a command line option to filter out the buildstats-diff report by
one more more tasks. e.g.:

 buildstats-diff --only-task do_compile A B

will only show the differences for do_compile tasks. The --only-task
option can be specified multiple times to filter out multiple tasks at
once.

(From OE-Core rev: a8c7960d24c48107fd3703e49c38f890e84e2226)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2019-07-15 10:47:33 -05:00
committed by Richard Purdie
parent 97ca346de8
commit 067d475dbb
2 changed files with 13 additions and 7 deletions

View File

@@ -261,13 +261,17 @@ class BuildStats(dict):
self[pkg].aggregate(data)
def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None):
def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None, only_tasks=[]):
"""Compare the tasks of two buildstats"""
tasks_diff = []
pkgs = set(bs1.keys()).union(set(bs2.keys()))
for pkg in pkgs:
tasks1 = bs1[pkg].tasks if pkg in bs1 else {}
tasks2 = bs2[pkg].tasks if pkg in bs2 else {}
if only_tasks:
tasks1 = {k: v for k, v in tasks1.items() if k in only_tasks}
tasks2 = {k: v for k, v in tasks2.items() if k in only_tasks}
if not tasks1:
pkg_op = '+'
elif not tasks2: