]> code.ossystems Code Review - openembedded-core.git/commitdiff
oe-build-perf-test: implement --globalres-file option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 23 Jun 2016 15:43:33 +0000 (18:43 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 1 Jul 2016 15:08:52 +0000 (16:08 +0100)
Using this option the script appends test results into a 'global results
file'. A CSV-formatted output of the results. This option is to provide
compatibility with the old build-perf-test.sh.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/buildperf/base.py
scripts/oe-build-perf-test

index e10cbf457245f68a94fa8c2549924fc50bf5fdc3..527563bb0b29538ef038d68316342cc6ebef74f2 100644 (file)
@@ -152,6 +152,38 @@ class BuildPerfTestRunner(object):
         os.makedirs(os.path.dirname(tgt_dir))
         shutil.copytree(src_dir, tgt_dir)
 
+    def update_globalres_file(self, filename):
+        """Write results to globalres csv file"""
+        if self.repo:
+            git_tag_rev = self.repo.run_cmd(['describe', self.git_rev])
+        else:
+            git_tag_rev = self.git_rev
+        times = []
+        sizes = []
+        for test in self.results['tests'].values():
+            for measurement in test['measurements']:
+                res_type = measurement['type']
+                values = measurement['values']
+                if res_type == BuildPerfTest.SYSRES:
+                    e_sec = values['elapsed_time'].total_seconds()
+                    times.append('{:d}:{:02d}:{:.2f}'.format(
+                        int(e_sec / 3600),
+                        int((e_sec % 3600) / 60),
+                        e_sec % 60))
+                elif res_type == BuildPerfTest.DISKUSAGE:
+                    sizes.append(str(values['size']))
+                else:
+                    log.warning("Unable to handle '%s' values in "
+                                "globalres.log", res_type)
+
+        log.debug("Writing globalres log to %s", filename)
+        with open(filename, 'a') as fobj:
+            fobj.write('{},{}:{},{},'.format(self.results['tester_host'],
+                                             self.results['git_branch'],
+                                             self.results['git_revision'],
+                                             git_tag_rev))
+            fobj.write(','.join(times + sizes) + '\n')
+
 
 def perf_test_case(obj):
     """Decorator for adding test classes"""
index ca90f69e1e8953a1015de32b8ba246b962b14d9e..9dd073cdfb4dee24658816f536fd1187f3f17edf 100755 (executable)
@@ -70,6 +70,8 @@ def parse_args(argv):
 
     parser.add_argument('-D', '--debug', action='store_true',
                         help='Enable debug level logging')
+    parser.add_argument('--globalres-file',
+                        help="Append results to 'globalres' csv file")
 
     return parser.parse_args(argv)
 
@@ -94,6 +96,9 @@ def main(argv=None):
     # Run actual tests
     runner = BuildPerfTestRunner(out_dir)
     ret = runner.run_tests()
+    if not ret:
+        if args.globalres_file:
+            runner.update_globalres_file(args.globalres_file)
 
     return ret