From 58a8ea9051829a30047602fed3aa19bd1abd395b Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Mon, 14 Aug 2017 15:39:40 +0100 Subject: [PATCH 1/3] Instrumentation/FPS: Fixes attribute checking Previously only the requirements for using SurfaceFlinger were checked, regardless of the FPS method being used. This commit now only ensure that a `View` attribute is present when using SurfaceFlinge and a `package` name is available if using gfxinfo otherwise falling back to SurfaceFlinger. --- wlauto/instrumentation/fps/__init__.py | 62 ++++++++++++++------------ 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/wlauto/instrumentation/fps/__init__.py b/wlauto/instrumentation/fps/__init__.py index 65fb0620..ad630bdb 100755 --- a/wlauto/instrumentation/fps/__init__.py +++ b/wlauto/instrumentation/fps/__init__.py @@ -158,37 +158,43 @@ class FpsInstrument(Instrument): def setup(self, context): workload = context.workload - if hasattr(workload, 'view'): - self.fps_outfile = os.path.join(context.output_directory, 'fps.csv') - self.outfile = os.path.join(context.output_directory, 'frames.csv') - # Android M brings a new method of collecting FPS data - if not self.force_surfaceflinger and (self.device.get_sdk_version() >= 23): - # gfxinfo takes in the package name rather than a single view/activity - # so there is no 'list_command' to run and compare against a list of - # views/activities. Additionally, clearing the stats requires the package - # so we need to clear for every package in the workload. - # Usually there is only one package, but some workloads may run multiple - # packages so each one must be reset before continuing - self.fps_method = 'gfxinfo' - runcmd = 'dumpsys gfxinfo {} framestats' - lstcmd = None - params = workload.package - params = [params] if isinstance(params, basestring) else params - for pkg in params: - self.device.execute('dumpsys gfxinfo {} reset'.format(pkg)) - else: - self.fps_method = 'surfaceflinger' - runcmd = 'dumpsys SurfaceFlinger --latency {}' - lstcmd = 'dumpsys SurfaceFlinger --list' - params = workload.view - self.device.execute('dumpsys SurfaceFlinger --latency-clear ') - self.collector = LatencyCollector(self.outfile, self.device, params or '', - self.keep_raw, self.logger, self.dumpsys_period, - runcmd, lstcmd, self.fps_method) - else: + use_gfxinfo = not self.force_surfaceflinger and (self.device.get_sdk_version() >= 23) + if use_gfxinfo and not hasattr(workload, 'package'): + self.logger.debug('Workload does not contain a package; falling back to SurfaceFlinger...') + use_gfxinfo = False + if not use_gfxinfo and not hasattr(workload, 'view'): self.logger.debug('Workload does not contain a view; disabling...') self.is_enabled = False + return + + self.fps_outfile = os.path.join(context.output_directory, 'fps.csv') + self.outfile = os.path.join(context.output_directory, 'frames.csv') + # Android M brings a new method of collecting FPS data + if use_gfxinfo: + # gfxinfo takes in the package name rather than a single view/activity + # so there is no 'list_command' to run and compare against a list of + # views/activities. Additionally, clearing the stats requires the package + # so we need to clear for every package in the workload. + # Usually there is only one package, but some workloads may run multiple + # packages so each one must be reset before continuing + self.fps_method = 'gfxinfo' + runcmd = 'dumpsys gfxinfo {} framestats' + lstcmd = None + params = workload.package + params = [params] if isinstance(params, basestring) else params + for pkg in params: + self.device.execute('dumpsys gfxinfo {} reset'.format(pkg)) + else: + self.fps_method = 'surfaceflinger' + runcmd = 'dumpsys SurfaceFlinger --latency {}' + lstcmd = 'dumpsys SurfaceFlinger --list' + params = workload.view + self.device.execute('dumpsys SurfaceFlinger --latency-clear ') + + self.collector = LatencyCollector(self.outfile, self.device, params or '', + self.keep_raw, self.logger, self.dumpsys_period, + runcmd, lstcmd, self.fps_method) def start(self, context): if self.is_enabled: From 10a614ff04471de26f92e37de19264171a5abff3 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Mon, 14 Aug 2017 15:45:52 +0100 Subject: [PATCH 2/3] Workload/Manual: Adds `package` parameter to workload Adds the `package` parameter to allow the workload to be used with the gfxinfo method of collecting data for the FPS instrument. --- wlauto/workloads/manual/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wlauto/workloads/manual/__init__.py b/wlauto/workloads/manual/__init__.py index 05e91f97..7519af35 100644 --- a/wlauto/workloads/manual/__init__.py +++ b/wlauto/workloads/manual/__init__.py @@ -29,11 +29,13 @@ class ManualWorkloadConfig(object): duration=None, # Seconds user_triggered=None, view=None, + package=None, enable_logcat=True ): self.user_triggered = user_triggered if user_triggered is not None else (False if duration else True) self.duration = duration or (None if self.user_triggered else self.default_duration) self.view = view + self.package = package self.enable_logcat = enable_logcat @@ -58,6 +60,12 @@ class ManualWorkload(Workload): Parameter('view', default='SurfaceView', description="""Specifies the View of the workload. This enables instruments that require a View to be specified, such as the ``fps`` instrument."""), + Parameter('package', + description="""Specifies the package name of the workload. This enables + instruments that require a Package to be specified, such + as the ``fps`` instrument. This allows for "gfxinfo" to + be used and is the preferred method of collection for FPS + statistics on devices API level 23+"""), Parameter('enable_logcat', kind=boolean, description='If ``True``, ``manual`` workload will collect logcat as part of the results.'), ] From 081358769d2ca323f3f19cf6076f016739030a19 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Tue, 15 Aug 2017 10:21:54 +0100 Subject: [PATCH 3/3] Workload/Manual: Update "view" parameter description --- wlauto/workloads/manual/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wlauto/workloads/manual/__init__.py b/wlauto/workloads/manual/__init__.py index 7519af35..190f0163 100644 --- a/wlauto/workloads/manual/__init__.py +++ b/wlauto/workloads/manual/__init__.py @@ -58,8 +58,10 @@ class ManualWorkload(Workload): is not specified, and ``False`` otherwise. """), Parameter('view', default='SurfaceView', - description="""Specifies the View of the workload. This enables instruments that require a - View to be specified, such as the ``fps`` instrument."""), + description="""Specifies the View of the workload. This enables instruments that + require a View to be specified, such as the ``fps`` instrument. + This is required for using "SurfaceFlinger" to collect FPS statistics + and is primarily used on devices pre API level 23"""), Parameter('package', description="""Specifies the package name of the workload. This enables instruments that require a Package to be specified, such