diff options
Diffstat (limited to 'scripts/lib/buildstats.py')
| -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 | |||
| 15 | import logging | 15 | import logging |
| 16 | import os | 16 | import os |
| 17 | import re | 17 | import re |
| 18 | from collections import namedtuple | 18 | from collections import namedtuple,OrderedDict |
| 19 | from statistics import mean | 19 | from 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 | |||
| 312 | class 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 | ||
