Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua G Lock <joshua.g.lock@linux.intel.com>
To: Markus Lehtonen <markus.lehtonen@linux.intel.com>,
	 openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 09/28] oeqa.buildperf: add BuildPerfTest class
Date: Mon, 27 Jun 2016 13:12:33 +0100	[thread overview]
Message-ID: <1467029553.2892.10.camel@linux.intel.com> (raw)
In-Reply-To: <1466764661-24544-10-git-send-email-markus.lehtonen@linux.intel.com>

On Fri, 2016-06-24 at 13:37 +0300, Markus Lehtonen wrote:
> The new class will be used as an abstract base class for build
> performance tests. This implementation contains some common
> functionality used in multiple tests, "copied" from the
> build-perf-test.sh shell script.
> 
> Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
> ---
>  meta/lib/oeqa/buildperf/__init__.py |  2 +-
>  meta/lib/oeqa/buildperf/base.py     | 78
> ++++++++++++++++++++++++++++++++++++-
>  2 files changed, 78 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/lib/oeqa/buildperf/__init__.py
> b/meta/lib/oeqa/buildperf/__init__.py
> index bab122e..3bee5b9 100644
> --- a/meta/lib/oeqa/buildperf/__init__.py
> +++ b/meta/lib/oeqa/buildperf/__init__.py
> @@ -10,4 +10,4 @@
>  # more details.
>  #
>  """Build performance tests"""
> -from .base import KernelDropCaches
> +from .base import BuildPerfTest, KernelDropCaches
> diff --git a/meta/lib/oeqa/buildperf/base.py
> b/meta/lib/oeqa/buildperf/base.py
> index 3cbdfa7..3ef0384 100644
> --- a/meta/lib/oeqa/buildperf/base.py
> +++ b/meta/lib/oeqa/buildperf/base.py
> @@ -10,7 +10,16 @@
>  # more details.
>  #
>  """Build performance test base classes and functionality"""
> -from oeqa.utils.commands import runCmd
> +import logging
> +import os
> +import shutil
> +import time
> +from datetime import datetime
> +
> +from oeqa.utils.commands import runCmd, get_bb_vars
> +
> +# Get logger for this module
> +log = logging.getLogger('build-perf')
>  
>  
>  class KernelDropCaches(object):
> @@ -44,3 +53,70 @@ class KernelDropCaches(object):
>          cmd += ['tee', '/proc/sys/vm/drop_caches']
>          input_data += b'3'
>          runCmd(cmd, data=input_data)
> +
> +
> +class BuildPerfTest(object):
> +    """Base class for build performance tests"""
> +    name = None
> +    description = None
> +
> +    def __init__(self, out_dir):
> +        self.out_dir = out_dir
> +        self.results = {'name':self.name,
> +                        'description': self.description,
> +                        'status': 'NOTRUN',
> +                        'start_time': None,
> +                        'elapsed_time': None,
> +                        'measurements': []}
> +        if not os.path.exists(self.out_dir):
> +            os.makedirs(self.out_dir)
> +        if not self.name:
> +            self.name = self.__class__.__name__
> +        self.bb_vars = get_bb_vars()
> +
> +    def run(self):
> +        """Run test"""
> +        self.results['status'] = 'FAILED'
> +        self.results['start_time'] = datetime.now()
> +        self._run()
> +        self.results['elapsed_time'] = (datetime.now() -
> +                                        self.results['start_time'])
> +        # Test is regarded as completed if it doesn't raise an
> exception
> +        self.results['status'] = 'COMPLETED'
> +
> +    def _run(self):
> +        """Actual test payload"""
> +        raise NotImplementedError
> +
> +    @staticmethod
> +    def force_rm(path):
> +        """Equivalent of 'rm -rf'"""

we have oe.path.remove() which does similar.

> +        if os.path.isfile(path) or os.path.islink(path):
> +            os.unlink(path)
> +        elif os.path.isdir(path):
> +            shutil.rmtree(path)
> +
> +    def rm_tmp(self):
> +        """Cleanup temporary/intermediate files and directories"""
> +        log.debug("Removing temporary and cache files")
> +        for name in ['bitbake.lock', 'conf/sanity_info',
> +                     self.bb_vars['TMPDIR']]:
> +            self.force_rm(name)
> +
> +    def rm_sstate(self):
> +        """Remove sstate directory"""
> +        log.debug("Removing sstate-cache")
> +        self.force_rm(self.bb_vars['SSTATE_DIR'])
> +
> +    def rm_cache(self):
> +        """Drop bitbake caches"""
> +        self.force_rm(self.bb_vars['PERSISTENT_DIR'])
> +
> +    @staticmethod
> +    def sync():
> +        """Sync and drop kernel caches"""
> +        log.debug("Syncing and dropping kernel caches""")
> +        KernelDropCaches.drop()
> +        os.sync()
> +        # Wait a bit for all the dirty blocks to be written onto
> disk
> +        time.sleep(3)
> -- 
> 2.6.6
> 


  reply	other threads:[~2016-06-27 12:12 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 10:37 [PATCH 00/28] Implement build performance test script in Python Markus Lehtonen
2016-06-24 10:37 ` [PATCH 01/28] oeqa.utils.commands: Introduce get_bb_vars() Markus Lehtonen
2016-06-24 10:37 ` [PATCH 02/28] oeqa.utils.commands: use get_bb_vars() in get_bb_var() Markus Lehtonen
2016-06-24 10:37 ` [PATCH 03/28] oeqa.utils.commands: runCmd: gracefully handle empty output Markus Lehtonen
2016-06-24 10:37 ` [PATCH 04/28] oeqa.utils.commands: runCmd: return stderr output, too Markus Lehtonen
2016-06-24 10:37 ` [PATCH 05/28] scripts: introduce oe-build-perf-test Markus Lehtonen
2016-06-24 10:37 ` [PATCH 06/28] oe-build-perf-test: add pre-run sanity check Markus Lehtonen
2016-06-24 10:37 ` [PATCH 07/28] oe-build-perf-test: introduce oeqa.buildperf module Markus Lehtonen
2016-06-24 10:37 ` [PATCH 08/28] oeqa.buildperf: functionality to drop kernel caches Markus Lehtonen
2016-06-24 10:37 ` [PATCH 09/28] oeqa.buildperf: add BuildPerfTest class Markus Lehtonen
2016-06-27 12:12   ` Joshua G Lock [this message]
2016-06-30 14:06     ` Markus Lehtonen
2016-06-24 10:37 ` [PATCH 10/28] oeqa.buildperf: method for measuring system resource usage Markus Lehtonen
2016-06-24 10:37 ` [PATCH 11/28] oeqa.buildperf: add method to log shell commands Markus Lehtonen
2016-06-24 10:37 ` [PATCH 12/28] oeqa.buildperf: add method for measuring file disk usage Markus Lehtonen
2016-06-24 10:37 ` [PATCH 13/28] oeqa.buildperf: add method for saving buildstats Markus Lehtonen
2016-06-24 10:37 ` [PATCH 14/28] oeqa.buildperf: implement BuildPerfTestRunner class Markus Lehtonen
2016-06-24 10:37 ` [PATCH 15/28] oeqa.buildperf: add test Test1P1 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 16/28] oeqa.buildperf: add test Test1P2 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 17/28] oeqa.buildperf: add test Test1P3 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 18/28] oeqa.buildperf: add test Test2 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 19/28] oeqa.buildperf: add test Test3 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 20/28] oeqa.buildperf: add test Test4 Markus Lehtonen
2016-06-24 10:37 ` [PATCH 21/28] oeqa.buildperf: archive build/conf into test results Markus Lehtonen
2016-06-24 10:37 ` [PATCH 22/28] oe-build-perf-test: enable logging into file Markus Lehtonen
2016-06-24 10:37 ` [PATCH 23/28] oeqa.utils: add git module Markus Lehtonen
2016-06-24 10:37 ` [PATCH 24/28] oeqa.buildperf: add git revision and branch to result data Markus Lehtonen
2016-06-24 10:37 ` [PATCH 25/28] oe-build-perf-test: implement --globalres-file option Markus Lehtonen
2016-06-24 10:37 ` [PATCH 26/28] oe-build-perf-test: enable locking Markus Lehtonen
2016-06-24 10:37 ` [PATCH 27/28] oe-build-perf-test: add --out-dir command line argument Markus Lehtonen
2016-06-24 10:37 ` [PATCH 28/28] scripts/contrib: introduce build-perf-test-wrapper.sh 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=1467029553.2892.10.camel@linux.intel.com \
    --to=joshua.g.lock@linux.intel.com \
    --cc=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