diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2017-01-19 12:16:45 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-23 12:05:22 +0000 |
commit | f4c96ea8292e9641214c32b5858d7653651b054f (patch) | |
tree | f3d1236aca42db182c5d3d10eb03b9f3cd1c786e | |
parent | 7171710acde94bafdefd676756b4a6617e6ae320 (diff) | |
download | poky-f4c96ea8292e9641214c32b5858d7653651b054f.tar.gz |
oeqa.buildperf: store measurements as a dict (object) in the JSON report
Store measurements as a dict, instead of an array, in the JSON report.
This change makes traversing of the report much easier. The change also
disallows identically named measurements under one test, as a sanity
check for the test cases.
[YOCTO #10590]
(From OE-Core rev: 81065092f38c9631dcf5917d70a25809a21de5f4)
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>
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py index 28c3e2901d..975524c6de 100644 --- a/meta/lib/oeqa/buildperf/base.py +++ b/meta/lib/oeqa/buildperf/base.py | |||
@@ -214,7 +214,7 @@ class BuildPerfTestResult(unittest.TextTestResult): | |||
214 | elif status not in ('SUCCESS', 'UNEXPECTED_SUCCESS'): | 214 | elif status not in ('SUCCESS', 'UNEXPECTED_SUCCESS'): |
215 | raise TypeError("BUG: invalid test status '%s'" % status) | 215 | raise TypeError("BUG: invalid test status '%s'" % status) |
216 | 216 | ||
217 | for data in test.measurements: | 217 | for data in test.measurements.values(): |
218 | measurement = ET.SubElement(testcase, data['type']) | 218 | measurement = ET.SubElement(testcase, data['type']) |
219 | measurement.set('name', data['name']) | 219 | measurement.set('name', data['name']) |
220 | measurement.set('legend', data['legend']) | 220 | measurement.set('legend', data['legend']) |
@@ -255,7 +255,7 @@ class BuildPerfTestCase(unittest.TestCase): | |||
255 | self.base_dir = None | 255 | self.base_dir = None |
256 | self.start_time = None | 256 | self.start_time = None |
257 | self.elapsed_time = None | 257 | self.elapsed_time = None |
258 | self.measurements = [] | 258 | self.measurements = OrderedDict() |
259 | # self.err is supposed to be a tuple from sys.exc_info() | 259 | # self.err is supposed to be a tuple from sys.exc_info() |
260 | self.err = None | 260 | self.err = None |
261 | self.bb_vars = get_bb_vars() | 261 | self.bb_vars = get_bb_vars() |
@@ -298,6 +298,13 @@ class BuildPerfTestCase(unittest.TestCase): | |||
298 | log.error("Command failed: %s", err.retcode) | 298 | log.error("Command failed: %s", err.retcode) |
299 | raise | 299 | raise |
300 | 300 | ||
301 | def _append_measurement(self, measurement): | ||
302 | """Simple helper for adding measurements results""" | ||
303 | if measurement['name'] in self.measurements: | ||
304 | raise ValueError('BUG: two measurements with the same name in {}'.format( | ||
305 | self.__class__.__name__)) | ||
306 | self.measurements[measurement['name']] = measurement | ||
307 | |||
301 | def measure_cmd_resources(self, cmd, name, legend, save_bs=False): | 308 | def measure_cmd_resources(self, cmd, name, legend, save_bs=False): |
302 | """Measure system resource usage of a command""" | 309 | """Measure system resource usage of a command""" |
303 | def _worker(data_q, cmd, **kwargs): | 310 | def _worker(data_q, cmd, **kwargs): |
@@ -357,7 +364,7 @@ class BuildPerfTestCase(unittest.TestCase): | |||
357 | measurement['values']['buildstats_file'] = \ | 364 | measurement['values']['buildstats_file'] = \ |
358 | os.path.relpath(bs_file, self.base_dir) | 365 | os.path.relpath(bs_file, self.base_dir) |
359 | 366 | ||
360 | self.measurements.append(measurement) | 367 | self._append_measurement(measurement) |
361 | 368 | ||
362 | # Append to 'times' array for globalres log | 369 | # Append to 'times' array for globalres log |
363 | e_sec = etime.total_seconds() | 370 | e_sec = etime.total_seconds() |
@@ -379,7 +386,7 @@ class BuildPerfTestCase(unittest.TestCase): | |||
379 | ('name', name), | 386 | ('name', name), |
380 | ('legend', legend)]) | 387 | ('legend', legend)]) |
381 | measurement['values'] = OrderedDict([('size', size)]) | 388 | measurement['values'] = OrderedDict([('size', size)]) |
382 | self.measurements.append(measurement) | 389 | self._append_measurement(measurement) |
383 | # Append to 'sizes' array for globalres log | 390 | # Append to 'sizes' array for globalres log |
384 | self.sizes.append(str(size)) | 391 | self.sizes.append(str(size)) |
385 | 392 | ||