mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-13 22:28:36 +00:00
Extra instrumentation for Slides
- Also: add benchmarking and dumpsys helper class/methods
This commit is contained in:
parent
edf2cb0e57
commit
39e96ed670
@ -20,9 +20,6 @@ from wlauto import AndroidUiAutoBenchmark, Parameter
|
||||
from wlauto.utils.types import list_of_strings
|
||||
|
||||
|
||||
def not_implemented(workload, text):
|
||||
workload.logger.info('## ++ NOT IMPLEMENTED ++ ##\n## {}\n## -- NOT IMPLEMENTED -- ##'.format(text))
|
||||
|
||||
def log_method(workload, name):
|
||||
workload.logger.info('===== {}() ======'.format(name))
|
||||
|
||||
@ -63,11 +60,12 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
||||
|
||||
def __init__(self, device, **kwargs):
|
||||
super(GoogleSlides, self).__init__(device, **kwargs)
|
||||
self.run_timeout = 300
|
||||
self.output_file = path.join(self.device.working_directory, self.instrumentation_log)
|
||||
self.local_dir = self.dependencies_directory
|
||||
self.device_dir = path.join(self.device.working_directory, '..', 'Download') # Android downloads folder
|
||||
# Android downloads folder
|
||||
self.device_dir = path.join(self.device.working_directory, '..', 'Download')
|
||||
self.wa_test_file = 'wa_test_' + self.local_file
|
||||
self.run_timeout = 300
|
||||
|
||||
def validate(self):
|
||||
log_method(self, 'validate')
|
||||
@ -89,8 +87,6 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
||||
self.device.push_file(path.join(self.local_dir, self.local_file),
|
||||
path.join(self.device_dir, self.wa_test_file),
|
||||
timeout=60)
|
||||
self.logger.info(path.join(self.local_dir, self.local_file))
|
||||
self.logger.info(path.join(self.device_dir, self.wa_test_file))
|
||||
|
||||
def setup(self, context):
|
||||
log_method(self, 'setup')
|
||||
@ -103,12 +99,12 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
||||
def update_result(self, context):
|
||||
log_method(self, 'update_result')
|
||||
super(GoogleSlides, self).update_result(context)
|
||||
not_implemented(self, 'self.get_metrics(context)')
|
||||
self.get_metrics(context)
|
||||
|
||||
def teardown(self, context):
|
||||
log_method(self, 'teardown')
|
||||
super(GoogleSlides, self).teardown(context)
|
||||
not_implemented(self, 'self.pull_logs(context)')
|
||||
self.pull_logs(context)
|
||||
|
||||
def finalize(self, context):
|
||||
log_method(self, 'finalize')
|
||||
@ -126,13 +122,16 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
||||
self.device.pull_file(self.output_file, context.output_directory)
|
||||
metrics_file = path.join(context.output_directory, self.instrumentation_log)
|
||||
with open(metrics_file, 'r') as wfh:
|
||||
regex = re.compile(r'(\w+)\s+(\d+)\s+(\d+)\s+(\d+)')
|
||||
regex = re.compile(r'(?P<key>\w+)\s+(?P<value1>\d+)\s+(?P<value2>\d+)\s+(?P<value3>\d+)')
|
||||
for line in wfh:
|
||||
match = regex.search(line)
|
||||
if match:
|
||||
context.result.add_metric((match.group(1) + '_start'), match.group(2))
|
||||
context.result.add_metric((match.group(1) + '_finish'), match.group(3))
|
||||
context.result.add_metric((match.group(1) + '_duration'), match.group(4))
|
||||
context.result.add_metric(match.group('key') + "_start",
|
||||
match.group('value1'), units='ms')
|
||||
context.result.add_metric(match.group('key') + "_finish",
|
||||
match.group('value2'), units='ms')
|
||||
context.result.add_metric(match.group('key') + "_duration",
|
||||
match.group('value3'), units='ms')
|
||||
|
||||
def pull_logs(self, context):
|
||||
wd = self.device.working_directory
|
||||
|
Binary file not shown.
@ -73,6 +73,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
+ "\t- IDs and Labels\n\tResult Processors and Instrumentation\n\t\t- Result Processors\n\t\t- Instrumentation\n\t"
|
||||
+ "\t- Disabling result processors and instrumentation\n\tOther Configuration (via config.py)\n";
|
||||
|
||||
protected Benchmarker bench = new Benchmarker();
|
||||
protected Map<String, Timer> results = new LinkedHashMap<String, Timer>();
|
||||
|
||||
protected Bundle parameters;
|
||||
@ -81,17 +82,50 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
protected String localFile;
|
||||
protected int slideCount;
|
||||
protected boolean useLocalFile;
|
||||
protected String resultsFile;
|
||||
|
||||
public void parseParams(Bundle parameters) throws Exception {
|
||||
dumpsysEnabled = Boolean.parseBoolean(parameters.getString("dumpsys_enabled"));
|
||||
outputDir = parameters.getString("output_dir");
|
||||
resultsFile = parameters.getString("results_file");
|
||||
localFile = parameters.getString("local_file", "");
|
||||
slideCount = Integer.parseInt(parameters.getString("slide_count"));
|
||||
useLocalFile = localFile != null;
|
||||
}
|
||||
|
||||
interface MeasurableAction {
|
||||
public void perform() throws Exception;
|
||||
}
|
||||
|
||||
public class Benchmarker {
|
||||
protected Map<String, Timer> benchResults = new LinkedHashMap<String, Timer>();
|
||||
|
||||
public Map<String, Timer> getResults() {
|
||||
return benchResults;
|
||||
}
|
||||
|
||||
public void measure(String tag, MeasurableAction action) throws Exception {
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
action.perform();
|
||||
timer.end();
|
||||
benchResults.put(tag, timer);
|
||||
}
|
||||
}
|
||||
|
||||
public void startDumpsys(String viewName) throws Exception {
|
||||
if (!dumpsysEnabled)
|
||||
return;
|
||||
initDumpsysSurfaceFlinger(PACKAGE, viewName);
|
||||
initDumpsysGfxInfo(PACKAGE);
|
||||
}
|
||||
|
||||
public void endDumpsys(String viewName, String testTag) throws Exception {
|
||||
if (!dumpsysEnabled)
|
||||
return;
|
||||
String dumpsysTag = TAG + "_" + testTag;
|
||||
exitDumpsysSurfaceFlinger(PACKAGE, viewName, new File(outputDir, dumpsysTag + "_surfFlinger.log"));
|
||||
exitDumpsysGfxInfo(PACKAGE, new File(outputDir, dumpsysTag + "_gfxInfo.log"));
|
||||
}
|
||||
|
||||
public void runUiAutomation() throws Exception {
|
||||
parameters = getParams();
|
||||
parseParams(parameters);
|
||||
@ -102,21 +136,48 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
} else {
|
||||
testEditNewSlidesDocument(NEW_DOC_FILENAME);
|
||||
}
|
||||
if (false) { // TODO currently unused
|
||||
writeResultsToFile(results, parameters.getString("results_file"));
|
||||
}
|
||||
results.putAll(bench.getResults());
|
||||
writeResultsToFile(results, parameters.getString("results_file"));
|
||||
}
|
||||
|
||||
protected void skipWelcomeScreen() throws Exception {
|
||||
String testTag = "skip_welcome";
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
clickView(BY_TEXT, "Skip", true);
|
||||
timer.end();
|
||||
results.put(testTag, timer);
|
||||
/*
|
||||
bench.measure(testTag, new MeasurableAction() {
|
||||
public void perform() throws Exception {
|
||||
clickView(BY_TEXT, "Skip", true);
|
||||
}
|
||||
});
|
||||
*/
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
protected void enablePowerpointCompat() throws Exception {
|
||||
String testTag = "enable_ppt_compat";
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
uiDeviceSwipeHorizontal(0, getDisplayWidth()/2, getDisplayHeight()/2);
|
||||
clickView(BY_TEXT, "Settings", true);
|
||||
clickView(BY_TEXT, "Create PowerPoint");
|
||||
getUiDevice().pressBack();
|
||||
timer.end();
|
||||
results.put(testTag, timer);
|
||||
/*
|
||||
bench.measure(testTag, new MeasurableAction() {
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
uiDeviceSwipeHorizontal(0, getDisplayWidth()/2, getDisplayHeight()/2);
|
||||
clickView(BY_TEXT, "Settings", true);
|
||||
clickView(BY_TEXT, "Create PowerPoint");
|
||||
getUiDevice().pressBack();
|
||||
}
|
||||
});
|
||||
*/
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user