diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2017-09-15 16:04:39 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-09-18 11:07:24 +0100 |
commit | 2f8942d6830258fcbe1925f12ba1516def32d132 (patch) | |
tree | 0aa54de331122a24e90e5110a05b222dd838aba8 /scripts/lib | |
parent | ddd9443cb2432af2c15b358bfda708393fa3c417 (diff) | |
download | openembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.tar.gz openembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.tar.bz2 openembedded-core-2f8942d6830258fcbe1925f12ba1516def32d132.zip |
scripts/buildstats-diff: move more code to lib/buildstats.py
More refactoring of buildstats-diff script. Move recipe version
comparison functionality to scripts/lib/buildstats.py. This patch also
compasses some wording changes, i.e. changing 'package' to 'recipe'.
[YOCTO #11382]
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/buildstats.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/scripts/lib/buildstats.py b/scripts/lib/buildstats.py index bd6332176a..b1c9e617c6 100644 --- a/scripts/lib/buildstats.py +++ b/scripts/lib/buildstats.py @@ -15,7 +15,7 @@ import json import logging import os import re -from collections import namedtuple +from collections import namedtuple,OrderedDict from statistics import mean @@ -307,3 +307,32 @@ def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None): tasks_diff.append(TaskDiff(pkg, pkg_op, task, task_op, val1, val2, val2-val1, reldiff)) return tasks_diff + + +class BSVerDiff(object): + """Class representing recipe version differences between two buildstats""" + def __init__(self, bs1, bs2): + RecipeVerDiff = namedtuple('RecipeVerDiff', 'left right') + + recipes1 = set(bs1.keys()) + recipes2 = set(bs2.keys()) + + self.new = dict([(r, bs2[r]) for r in sorted(recipes2 - recipes1)]) + self.dropped = dict([(r, bs1[r]) for r in sorted(recipes1 - recipes2)]) + self.echanged = {} + self.vchanged = {} + self.rchanged = {} + self.unchanged = {} + + common = recipes2.intersection(recipes1) + if common: + for recipe in common: + rdiff = RecipeVerDiff(bs1[recipe], bs2[recipe]) + if bs1[recipe].epoch != bs2[recipe].epoch: + self.echanged[recipe] = rdiff + elif bs1[recipe].version != bs2[recipe].version: + self.vchanged[recipe] = rdiff + elif bs1[recipe].revision != bs2[recipe].revision: + self.rchanged[recipe] = rdiff + else: + self.unchanged[recipe] = rdiff |