summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-09-15 16:04:39 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-18 11:07:30 +0100
commita80f5e761cf1c0ac1b5d457ec5284f601c60f459 (patch)
treeb85f3b9abc60fe78008da1ae94b39fb785ae7364 /scripts/lib
parent81aef784fdbd2e8a543475b1892c3d6a1fe97872 (diff)
downloadpoky-a80f5e761cf1c0ac1b5d457ec5284f601c60f459.tar.gz
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] (From OE-Core rev: 2f8942d6830258fcbe1925f12ba1516def32d132) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/buildstats.py31
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
15import logging 15import logging
16import os 16import os
17import re 17import re
18from collections import namedtuple 18from collections import namedtuple,OrderedDict
19from statistics import mean 19from statistics import mean
20 20
21 21
@@ -307,3 +307,32 @@ def diff_buildstats(bs1, bs2, stat_attr, min_val=None, min_absdiff=None):
307 tasks_diff.append(TaskDiff(pkg, pkg_op, task, task_op, val1, val2, 307 tasks_diff.append(TaskDiff(pkg, pkg_op, task, task_op, val1, val2,
308 val2-val1, reldiff)) 308 val2-val1, reldiff))
309 return tasks_diff 309 return tasks_diff
310
311
312class BSVerDiff(object):
313 """Class representing recipe version differences between two buildstats"""
314 def __init__(self, bs1, bs2):
315 RecipeVerDiff = namedtuple('RecipeVerDiff', 'left right')
316
317 recipes1 = set(bs1.keys())
318 recipes2 = set(bs2.keys())
319
320 self.new = dict([(r, bs2[r]) for r in sorted(recipes2 - recipes1)])
321 self.dropped = dict([(r, bs1[r]) for r in sorted(recipes1 - recipes2)])
322 self.echanged = {}
323 self.vchanged = {}
324 self.rchanged = {}
325 self.unchanged = {}
326
327 common = recipes2.intersection(recipes1)
328 if common:
329 for recipe in common:
330 rdiff = RecipeVerDiff(bs1[recipe], bs2[recipe])
331 if bs1[recipe].epoch != bs2[recipe].epoch:
332 self.echanged[recipe] = rdiff
333 elif bs1[recipe].version != bs2[recipe].version:
334 self.vchanged[recipe] = rdiff
335 elif bs1[recipe].revision != bs2[recipe].revision:
336 self.rchanged[recipe] = rdiff
337 else:
338 self.unchanged[recipe] = rdiff