1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 04:21:17 +00:00

Add logging and exception handling to uxperf result processor

The uxperf result processor now provides warnings for unmatched UX_PERF
markers when running the fps instrument. Previously unmatched markers
resulted in an exception being thrown. Includes additional logging for
debugging purposes.
This commit is contained in:
John Richardson 2016-07-25 14:45:46 +01:00
parent 625a3a39a5
commit da19859c25

View File

@ -15,6 +15,7 @@
import os import os
import re import re
import logging
from collections import defaultdict from collections import defaultdict
from distutils.version import LooseVersion from distutils.version import LooseVersion
@ -86,12 +87,15 @@ class UxPerfResultProcessor(ResultProcessor):
logfile = os.path.join(context.output_directory, 'logcat.log') logfile = os.path.join(context.output_directory, 'logcat.log')
framelog = os.path.join(context.output_directory, 'frames.csv') framelog = os.path.join(context.output_directory, 'frames.csv')
self.logger.debug('Parsing logcat.log for UX_PERF markers')
parser.parse(logfile) parser.parse(logfile)
if self.add_timings: if self.add_timings:
self.logger.debug('Adding per-action timings')
parser.add_action_timings() parser.add_action_timings()
if self.add_frames: if self.add_frames:
self.logger.debug('Adding per-action frame metrics')
parser.add_action_frames(framelog, self.drop_threshold, self.generate_csv) parser.add_action_frames(framelog, self.drop_threshold, self.generate_csv)
@ -116,6 +120,7 @@ class UxPerfParser(object):
def __init__(self, context): def __init__(self, context):
self.context = context self.context = context
self.actions = defaultdict(list) self.actions = defaultdict(list)
self.logger = logging.getLogger('UxPerfParser')
# regex for matching logcat message format: # regex for matching logcat message format:
# date time PID-TID/package priority/tag: message # date time PID-TID/package priority/tag: message
@ -146,8 +151,14 @@ class UxPerfParser(object):
refresh_period = self._parse_refresh_peroid() refresh_period = self._parse_refresh_peroid()
for action in self.actions: for action in self.actions:
# default values
fps = float('nan')
frame_count, janks, not_at_vsync = 0, 0, 0
metrics = fps, frame_count, janks, not_at_vsync
df = self._create_data_dict(action, frames) df = self._create_data_dict(action, frames)
fp = FpsProcessor(pd.DataFrame(df), action=action) fp = FpsProcessor(pd.DataFrame(df), action=action)
try:
per_frame_fps, metrics = fp.process(refresh_period, drop_threshold) per_frame_fps, metrics = fp.process(refresh_period, drop_threshold)
if generate_csv: if generate_csv:
@ -156,6 +167,9 @@ class UxPerfParser(object):
fps_outfile = os.path.join(self.context.output_directory, filename) fps_outfile = os.path.join(self.context.output_directory, filename)
per_frame_fps.to_csv(fps_outfile, index=False, header=True) per_frame_fps.to_csv(fps_outfile, index=False, header=True)
self.context.add_artifact(name, path=filename, kind='data') self.context.add_artifact(name, path=filename, kind='data')
except AttributeError:
self.logger.warning('Non-matched timestamps in dumpsys output: action={}'
.format(action))
fps, frame_count, janks, not_at_vsync = metrics fps, frame_count, janks, not_at_vsync = metrics
result = self.context.result result = self.context.result
@ -232,14 +246,16 @@ class UxPerfParser(object):
return d return d
@staticmethod def _read(self, log):
def _read(log):
''' '''
Opens a file a yields the lines with whitespace stripped. Opens a file a yields the lines with whitespace stripped.
''' '''
try:
with open(log, 'r') as rfh: with open(log, 'r') as rfh:
for line in rfh: for line in rfh:
yield line.strip() yield line.strip()
except IOError:
self.logger.error('Could not open {}'.format(log))
@staticmethod @staticmethod
def _matched_rows(rows, timestamps): def _matched_rows(rows, timestamps):