1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 12:24:32 +00:00

Merge pull request #179 from setrofim/master

bbench and recentfling fixes
This commit is contained in:
Sebastian Goscik 2016-06-14 10:22:20 +01:00 committed by GitHub
commit 3a90309383
2 changed files with 30 additions and 15 deletions

View File

@ -24,7 +24,7 @@ import re
from collections import defaultdict from collections import defaultdict
from wlauto import settings, Workload, Parameter, Alias, Executable from wlauto import settings, Workload, Parameter, Alias, Executable
from wlauto.exceptions import ConfigError from wlauto.exceptions import ConfigError, WorkloadError
from wlauto.utils.types import boolean from wlauto.utils.types import boolean
DEFAULT_BBENCH_FILE = "http://bbench.eecs.umich.edu/bbench/bbench_2.0.tgz" DEFAULT_BBENCH_FILE = "http://bbench.eecs.umich.edu/bbench/bbench_2.0.tgz"
@ -158,6 +158,9 @@ class BBench(Workload):
metrics = _parse_metrics(os.path.join(context.output_directory, 'browser_bbench_logcat.txt'), metrics = _parse_metrics(os.path.join(context.output_directory, 'browser_bbench_logcat.txt'),
os.path.join(context.output_directory, 'index_noinput.html'), os.path.join(context.output_directory, 'index_noinput.html'),
context.output_directory) context.output_directory)
if not metrics:
raise WorkloadError('No BBench metrics extracted from Logcat')
for key, values in metrics: for key, values in metrics:
for i, value in enumerate(values): for i, value in enumerate(values):
metric = '{}_{}'.format(key, i) if i else key metric = '{}_{}'.format(key, i) if i else key
@ -217,6 +220,7 @@ def _parse_metrics(logfile, indexfile, output_directory): # pylint: disable=R09
settings_dict['iterations'], settings_dict['scrollDelay'], settings_dict['scrollSize'] = match.group(1).split(',') settings_dict['iterations'], settings_dict['scrollDelay'], settings_dict['scrollSize'] = match.group(1).split(',')
with open(logfile) as fh: with open(logfile) as fh:
results_dict = defaultdict(list) results_dict = defaultdict(list)
results_list = []
for line in fh: for line in fh:
if 'metrics:Mean' in line: if 'metrics:Mean' in line:
results_list = regex_bbscore.findall(line) results_list = regex_bbscore.findall(line)
@ -241,4 +245,4 @@ def _parse_metrics(logfile, indexfile, output_directory): # pylint: disable=R09
with open(os.path.join(output_directory, 'settings.json'), 'w') as wfh: with open(os.path.join(output_directory, 'settings.json'), 'w') as wfh:
json.dump(settings_dict, wfh) json.dump(settings_dict, wfh)
return sorted_results return list(sorted_results)

View File

@ -21,7 +21,7 @@ from collections import defaultdict
from wlauto import Workload, Parameter, File from wlauto import Workload, Parameter, File
from wlauto.utils.types import caseless_string from wlauto.utils.types import caseless_string
from wlauto.exceptions import WorkloadError from wlauto.exceptions import WorkloadError, DeviceError
class Recentfling(Workload): class Recentfling(Workload):
@ -32,7 +32,7 @@ class Recentfling(Workload):
For this workload to work, ``recentfling.sh`` and ``defs.sh`` must be placed For this workload to work, ``recentfling.sh`` and ``defs.sh`` must be placed
in ``~/.workload_automation/dependencies/recentfling/``. These can be found in ``~/.workload_automation/dependencies/recentfling/``. These can be found
in the `AOSP Git repository <https://android.googlesource.com/platform/system/extras/+/master/tests/>`_. in the `AOSP Git repository <https://android.googlesource.com/platform/system/extras/+/master/tests/workloads>`_.
To change the apps that are opened at the start of the workload you will need To change the apps that are opened at the start of the workload you will need
to modify the ``defs.sh`` file. You will need to add your app to ``dfltAppList`` to modify the ``defs.sh`` file. You will need to add your app to ``dfltAppList``
@ -47,6 +47,12 @@ class Recentfling(Workload):
parameters = [ parameters = [
Parameter('loops', kind=int, default=3, Parameter('loops', kind=int, default=3,
description="The number of test iterations."), description="The number of test iterations."),
Parameter('start_apps', kind=bool, default=True,
description="""
If set to ``False``,no apps will be started before flinging
through the recent apps list (in which the assumption is
there are already recently started apps in the list.
"""),
] ]
def initialise(self, context): # pylint: disable=no-self-use def initialise(self, context): # pylint: disable=no-self-use
@ -56,15 +62,18 @@ class Recentfling(Workload):
def setup(self, context): def setup(self, context):
self.defs_host = context.resolver.get(File(self, "defs.sh")) self.defs_host = context.resolver.get(File(self, "defs.sh"))
self.defs_target = self.device.install(self.defs_host)
self.recentfling_host = context.resolver.get(File(self, "recentfling.sh")) self.recentfling_host = context.resolver.get(File(self, "recentfling.sh"))
self.device.push_file(self.recentfling_host, self.device.working_directory) self.recentfling_target = self.device.install(self.recentfling_host)
self.device.push_file(self.defs_host, self.device.working_directory)
self._kill_recentfling() self._kill_recentfling()
self.device.ensure_screen_is_on() self.device.ensure_screen_is_on()
def run(self, context): def run(self, context):
cmd = "echo $$>{dir}/pidfile; exec {dir}/recentfling.sh -i {}; rm {dir}/pidfile" args = '-i {} '.format(self.loops)
cmd = cmd.format(self.loops, dir=self.device.working_directory) if not self.start_apps:
args += '-N '
cmd = "echo $$>{dir}/pidfile; cd {bindir}; exec ./recentfling.sh {args}; rm {dir}/pidfile"
cmd = cmd.format(args=args, dir=self.device.working_directory, bindir=self.device.binaries_directory)
try: try:
self.output = self.device.execute(cmd, timeout=120) self.output = self.device.execute(cmd, timeout=120)
except KeyboardInterrupt: except KeyboardInterrupt:
@ -89,12 +98,14 @@ class Recentfling(Workload):
classifiers={"loop": count or "Average"}) classifiers={"loop": count or "Average"})
def teardown(self, context): def teardown(self, context):
self.device.delete_file(self.device.path.join(self.device.working_directory, self.device.uninstall(self.recentfling_target)
"recentfling.sh")) self.device.uninstall(self.defs_target)
self.device.delete_file(self.device.path.join(self.device.working_directory,
"defs.sh"))
def _kill_recentfling(self): def _kill_recentfling(self):
pid = self.device.execute('cat {}/pidfile'.format(self.device.working_directory)) command = 'cat {}/pidfile'.format(self.device.working_directory)
if pid: try:
self.device.kill(pid.strip(), signal='SIGKILL') pid = self.device.execute(command)
if pid.strip():
self.device.kill(pid.strip(), signal='SIGKILL')
except DeviceError:
pass # may have already been deleted