summaryrefslogtreecommitdiff
path: root/meta/lib
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-01-19 12:16:45 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:04:00 +0000
commit81065092f38c9631dcf5917d70a25809a21de5f4 (patch)
tree1b08c8d42e77286d319b7bba4e5544914c8b3af4 /meta/lib
parent75e8aec0e0d81888be47b35c3c84df73edb91868 (diff)
downloadopenembedded-core-81065092f38c9631dcf5917d70a25809a21de5f4.tar.gz
openembedded-core-81065092f38c9631dcf5917d70a25809a21de5f4.tar.bz2
openembedded-core-81065092f38c9631dcf5917d70a25809a21de5f4.zip
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] Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/buildperf/base.py15
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):
elif status not in ('SUCCESS', 'UNEXPECTED_SUCCESS'):
raise TypeError("BUG: invalid test status '%s'" % status)
- for data in test.measurements:
+ for data in test.measurements.values():
measurement = ET.SubElement(testcase, data['type'])
measurement.set('name', data['name'])
measurement.set('legend', data['legend'])
@@ -255,7 +255,7 @@ class BuildPerfTestCase(unittest.TestCase):
self.base_dir = None
self.start_time = None
self.elapsed_time = None
- self.measurements = []
+ self.measurements = OrderedDict()
# self.err is supposed to be a tuple from sys.exc_info()
self.err = None
self.bb_vars = get_bb_vars()
@@ -298,6 +298,13 @@ class BuildPerfTestCase(unittest.TestCase):
log.error("Command failed: %s", err.retcode)
raise
+ def _append_measurement(self, measurement):
+ """Simple helper for adding measurements results"""
+ if measurement['name'] in self.measurements:
+ raise ValueError('BUG: two measurements with the same name in {}'.format(
+ self.__class__.__name__))
+ self.measurements[measurement['name']] = measurement
+
def measure_cmd_resources(self, cmd, name, legend, save_bs=False):
"""Measure system resource usage of a command"""
def _worker(data_q, cmd, **kwargs):
@@ -357,7 +364,7 @@ class BuildPerfTestCase(unittest.TestCase):
measurement['values']['buildstats_file'] = \
os.path.relpath(bs_file, self.base_dir)
- self.measurements.append(measurement)
+ self._append_measurement(measurement)
# Append to 'times' array for globalres log
e_sec = etime.total_seconds()
@@ -379,7 +386,7 @@ class BuildPerfTestCase(unittest.TestCase):
('name', name),
('legend', legend)])
measurement['values'] = OrderedDict([('size', size)])
- self.measurements.append(measurement)
+ self._append_measurement(measurement)
# Append to 'sizes' array for globalres log
self.sizes.append(str(size))