From 065ebaac61979b0eee44e73ed81a7568bc623126 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Thu, 3 Dec 2015 14:45:52 +0000 Subject: [PATCH] hwuitest: Added workload This workload allow WA to use hwuitest from AOSP to test rendering latency on Android devices. --- wlauto/workloads/hwuitest/__init__.py | 108 ++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 wlauto/workloads/hwuitest/__init__.py diff --git a/wlauto/workloads/hwuitest/__init__.py b/wlauto/workloads/hwuitest/__init__.py new file mode 100644 index 00000000..00e18f1d --- /dev/null +++ b/wlauto/workloads/hwuitest/__init__.py @@ -0,0 +1,108 @@ +# Copyright 2013-2015 ARM Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#pylint: disable=E1101,W0201 + +import os +import re +from collections import defaultdict + +from wlauto import Workload, Parameter, Executable +from wlauto.utils.types import caseless_string + + +BINARY = "hwuitest" +IGNORED_METRICS = ["Stats since", "Total frames rendered"] + + +class HWUITest(Workload): + + name = 'hwuitest' + description = """ + Tests UI rendering latency on android devices + """ + supported_platforms = ['android'] + + parameters = [ + Parameter('test', kind=caseless_string, default="shadowgrid", + allowed_values=["shadowgrid", "rectgrid", "oval"], + description=""" + The test to run: + - ``'shadowgrid'``: creates a grid of rounded rects that + cast shadows, high CPU & GPU load + - ``'rectgrid'``: creates a grid of 1x1 rects + - ``'oval'``: draws 1 oval + """), + Parameter('loops', kind=int, default=3, + description="The number of test iterations."), + Parameter('frames', kind=int, default=150, + description="The number of frames to run the test over."), + ] + + def setup(self, context): + host_exe = context.resolver.get(Executable(self, + self.device.abi, + BINARY)) + self.device.install(host_exe) + + def run(self, context): + self.output = self.device.execute("{} {} {} {}".format(BINARY, + self.test.lower(), + self.loops, + self.frames)) + + def update_result(self, context): + outfile = os.path.join(context.output_directory, 'hwuitest.output') + with open(outfile, 'w') as wfh: + wfh.write(self.output) + context.add_artifact('hwuitest', outfile, kind='raw') + + normal = re.compile(r'(?P\d*)(?P\w*)') + with_pct = re.compile(r'(?P\d*) \((?P.*)%\)') + count = 0 + for line in self.output.splitlines(): + #Filters out "Success!" and blank lines + try: + metric, value_string = [p.strip() for p in line.split(':', 1)] + except ValueError: + continue + + # Filters out unwanted lines + if metric in IGNORED_METRICS: + continue + + if metric == "Janky frames": + count += 1 + match = with_pct.match(value_string).groupdict() + context.result.add_metric(metric, + match['value'], + None, + classifiers={"loop": count, + "frames": self.frames}) + context.result.add_metric(metric + "_pct", + match['value'], + "%", + classifiers={"loop": count, + "frames": self.frames}) + else: + match = normal.match(value_string).groupdict() + context.result.add_metric(metric, + match['value'], + match['unit'], + classifiers={"loop": count, + "frames": self.frames}) + + def teardown(self, context): + self.device.uninstall_executable(BINARY)