public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 11/12] oeqa.buildperf: include buildstats file name in results.json
Date: Mon, 29 Aug 2016 22:48:30 +0300	[thread overview]
Message-ID: <1472500111-12358-12-git-send-email-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <1472500111-12358-1-git-send-email-markus.lehtonen@linux.intel.com>

No need to do lsdir magic for finding buildstats when reading results.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
 meta/lib/oeqa/buildperf/base.py       | 18 ++++++++++++++----
 meta/lib/oeqa/buildperf/test_basic.py |  7 +++----
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index 49da8f6..0b2c0f8 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -141,7 +141,7 @@ class BuildPerfTestResult(unittest.TextTestResult):
 
     def startTest(self, test):
         """Pre-test hook"""
-        test.out_dir = os.path.join(self.out_dir, test.name)
+        test.base_dir = self.out_dir
         os.mkdir(test.out_dir)
         log.info("Executing test %s: %s", test.name, test.shortDescription())
         self.stream.write(datetime.now().strftime("[%Y-%m-%d %H:%M:%S] "))
@@ -298,7 +298,7 @@ class BuildPerfTestCase(unittest.TestCase):
     def __init__(self, *args, **kwargs):
         super(BuildPerfTestCase, self).__init__(*args, **kwargs)
         self.name = self._testMethodName
-        self.out_dir = None
+        self.base_dir = None
         self.start_time = None
         self.elapsed_time = None
         self.measurements = []
@@ -308,6 +308,10 @@ class BuildPerfTestCase(unittest.TestCase):
         self.times = []
         self.sizes = []
 
+    @property
+    def out_dir(self):
+        return os.path.join(self.base_dir, self.name)
+
     def setUp(self):
         """Set-up fixture for each test"""
         if self.build_target:
@@ -332,7 +336,7 @@ class BuildPerfTestCase(unittest.TestCase):
             log.error("Command failed: %s", err.retcode)
             raise
 
-    def measure_cmd_resources(self, cmd, name, legend):
+    def measure_cmd_resources(self, cmd, name, legend, save_bs=False):
         """Measure system resource usage of a command"""
         def _worker(data_q, cmd, **kwargs):
             """Worker process for measuring resources"""
@@ -387,6 +391,11 @@ class BuildPerfTestCase(unittest.TestCase):
                                  'elapsed_time': etime,
                                  'rusage': data['rusage'],
                                  'iostat': data['iostat']}
+        if save_bs:
+            bs_file = self.save_buildstats(legend)
+            measurement['values']['buildstats_file'] = \
+                    os.path.relpath(bs_file, self.base_dir)
+
         self.measurements.append(measurement)
 
         # Append to 'times' array for globalres log
@@ -474,12 +483,13 @@ class BuildPerfTestCase(unittest.TestCase):
             buildstats.append(recipe_bs)
 
         # Write buildstats into json file
-        postfix = '.' + label if label else ''
+        postfix = '.' + str_to_fn(label) if label else ''
         postfix += '.json'
         outfile = os.path.join(self.out_dir, 'buildstats' + postfix)
         with open(outfile, 'w') as fobj:
             json.dump(buildstats, fobj, indent=4, sort_keys=True,
                       cls=ResultsJsonEncoder)
+        return outfile
 
     def rm_tmp(self):
         """Cleanup temporary/intermediate files and directories"""
diff --git a/meta/lib/oeqa/buildperf/test_basic.py b/meta/lib/oeqa/buildperf/test_basic.py
index 25dbfb0..e448ed1 100644
--- a/meta/lib/oeqa/buildperf/test_basic.py
+++ b/meta/lib/oeqa/buildperf/test_basic.py
@@ -28,9 +28,8 @@ class Test1P1(BuildPerfTestCase):
         self.rm_cache()
         self.sync()
         self.measure_cmd_resources(['bitbake', self.build_target], 'build',
-                                   'bitbake ' + self.build_target)
+                                   'bitbake ' + self.build_target, save_bs=True)
         self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
-        self.save_buildstats()
 
 
 class Test1P2(BuildPerfTestCase):
@@ -62,11 +61,11 @@ class Test1P3(BuildPerfTestCase):
             self.sync()
             cmd = ['bitbake', '-R', postfile, self.build_target]
             self.measure_cmd_resources(cmd, 'build',
-                                       'bitbake' + self.build_target)
+                                       'bitbake' + self.build_target,
+                                       save_bs=True)
             self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
         finally:
             os.unlink(postfile)
-        self.save_buildstats()
 
 
 class Test2(BuildPerfTestCase):
-- 
2.6.6



  parent reply	other threads:[~2016-08-29 19:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29 19:48 [PATCH 00/12] oe-build-perf-test: new format for test output data Markus Lehtonen
2016-08-29 19:48 ` [PATCH 01/12] oeqa.buildperf: add 'product' to test result data Markus Lehtonen
2016-08-29 19:48 ` [PATCH 02/12] oeqa.buildperf: enable json-formatted results Markus Lehtonen
2016-08-29 19:48 ` [PATCH 03/12] oe-build-perf-test: rename log file and implement --log-file Markus Lehtonen
2016-08-29 19:48 ` [PATCH 04/12] oeqa.buildperf: strip date from buildstats directory path Markus Lehtonen
2016-08-29 19:48 ` [PATCH 05/12] oeqa.buildperf: separate output dir for each test Markus Lehtonen
2016-08-29 19:48 ` [PATCH 06/12] oeqa.buildperf: rename buildstats directories Markus Lehtonen
2016-08-29 19:48 ` [PATCH 07/12] oeqa.buildperf: don't use Gnu time Markus Lehtonen
2016-08-29 19:48 ` [PATCH 08/12] oeqa.buildperf: measure io stat Markus Lehtonen
2016-08-29 19:48 ` [PATCH 09/12] oeqa.buildperf: convert buildstats into json format Markus Lehtonen
2016-08-29 19:48 ` [PATCH 10/12] oeqa.buildperf: show skipped tests in results, too Markus Lehtonen
2016-08-29 19:48 ` Markus Lehtonen [this message]
2016-08-29 19:48 ` [PATCH 12/12] oeqa.buildperf: include commands log file name in results.json Markus Lehtonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472500111-12358-12-git-send-email-markus.lehtonen@linux.intel.com \
    --to=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox