mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 20:11:20 +00:00
workloads/gfxbench: Rework score detection
Rework how the result matching is performed. Some tests from gfxbench provide more than 1 score per test and some provide their output in a different format to others. Update the matching to perform more flexible matching as well as dealing with entries that do not fit on a single results screen.
This commit is contained in:
parent
586d95a4f0
commit
443358f513
@ -23,7 +23,7 @@ class Gfxbench(ApkUiautoWorkload):
|
|||||||
name = 'gfxbench-corporate'
|
name = 'gfxbench-corporate'
|
||||||
package_names = ['net.kishonti.gfxbench.gl.v50000.corporate']
|
package_names = ['net.kishonti.gfxbench.gl.v50000.corporate']
|
||||||
clear_data_on_reset = False
|
clear_data_on_reset = False
|
||||||
score_regex = re.compile(r'.*?([\d.]+).*')
|
regex_template = 'name: \((?P<test_name>.*)\).*result: \((?P<result>.*)?\).* sub_result:.*\((?P<sub_result>.*?)?\).*'
|
||||||
description = '''
|
description = '''
|
||||||
Execute a subset of graphical performance benchmarks
|
Execute a subset of graphical performance benchmarks
|
||||||
|
|
||||||
@ -58,26 +58,43 @@ class Gfxbench(ApkUiautoWorkload):
|
|||||||
self.gui.timeout = self.timeout
|
self.gui.timeout = self.timeout
|
||||||
self.gui.uiauto_params['tests'] = self.tests
|
self.gui.uiauto_params['tests'] = self.tests
|
||||||
|
|
||||||
|
# pylint: disable=too-many-locals
|
||||||
def update_output(self, context):
|
def update_output(self, context):
|
||||||
super(Gfxbench, self).update_output(context)
|
super(Gfxbench, self).update_output(context)
|
||||||
expected_results = len(self.tests)
|
regex_matches = [re.compile(self.regex_template.format(t)) for t in self.tests]
|
||||||
regex_matches = [re.compile('{} score (.+)'.format(t)) for t in self.tests]
|
|
||||||
logcat_file = context.get_artifact_path('logcat')
|
logcat_file = context.get_artifact_path('logcat')
|
||||||
|
found = []
|
||||||
|
detected_results = 0
|
||||||
|
failed = False
|
||||||
with open(logcat_file, errors='replace') as fh:
|
with open(logcat_file, errors='replace') as fh:
|
||||||
for line in fh:
|
for line in fh:
|
||||||
for regex in regex_matches:
|
for regex in regex_matches:
|
||||||
match = regex.search(line)
|
match = regex.search(line)
|
||||||
# Check if we have matched the score string in logcat
|
# Check if we have matched the score string in logcat and not already found.
|
||||||
if match:
|
if match and match.group('test_name') not in found:
|
||||||
score_match = self.score_regex.search(match.group(1))
|
found.append(match.group('test_name'))
|
||||||
# Check if there is valid number found for the score.
|
# Set Default values
|
||||||
if score_match:
|
result = 'NaN'
|
||||||
result = float(score_match.group(1))
|
unit = 'FPS'
|
||||||
else:
|
|
||||||
result = 'NaN'
|
# For most tests we usually want the `sub_result`
|
||||||
entry = regex.pattern.rsplit(None, 1)[0]
|
# as this is our FPS value
|
||||||
context.add_metric(entry, result, 'FPS', lower_is_better=False)
|
try:
|
||||||
expected_results -= 1
|
result = float(match.group('sub_result').split()[0].replace(',', ''))
|
||||||
if expected_results > 0:
|
except (ValueError, TypeError):
|
||||||
msg = "The GFXBench workload has failed. Expected {} scores, Detected {} scores."
|
# However for some tests the value is stored in `result`
|
||||||
raise WorkloadError(msg.format(len(self.regex_matches), expected_results))
|
# and the unit is saved in the `sub_result`.
|
||||||
|
try:
|
||||||
|
result = float(match.group('result').replace(',', ''))
|
||||||
|
if match.group('sub_result'):
|
||||||
|
unit = match.group('sub_result').upper()
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
failed = True
|
||||||
|
|
||||||
|
entry = match.group('test_name')
|
||||||
|
context.add_metric(entry, result, unit, lower_is_better=False)
|
||||||
|
detected_results += 1
|
||||||
|
|
||||||
|
if failed or detected_results < len(regex_matches):
|
||||||
|
msg = "The workload has failed to process all scores. Expected >={} scores, Detected {} scores."
|
||||||
|
raise WorkloadError(msg.format(len(regex_matches), detected_results))
|
||||||
|
Binary file not shown.
@ -142,15 +142,36 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getScores() throws Exception {
|
public void getScores() throws Exception {
|
||||||
UiScrollable list = new UiScrollable(new UiSelector().scrollable(true));
|
// To ensure we print all scores, some will be printed multiple times but these are filtered on the python side.
|
||||||
|
UiScrollable scrollable = new UiScrollable(new UiSelector().scrollable(true));
|
||||||
UiObject results =
|
// Start at the bottom of the list as this seems more reliable when extracting results.
|
||||||
mDevice.findObject(new UiSelector().resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/results_testList"));
|
scrollable.flingToEnd(10);
|
||||||
|
Boolean top_of_list = false;
|
||||||
for (String test : testList) {
|
while(true) {
|
||||||
getTestScore(list, results, test);
|
UiObject resultsList =
|
||||||
|
mDevice.findObject(new UiSelector().resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/results_testList"));
|
||||||
|
// Find the element in the list that contains our test and pull result and sub_result
|
||||||
|
for (int i=1; i < resultsList.getChildCount(); i++) {
|
||||||
|
UiObject testName = resultsList.getChild(new UiSelector().index(i))
|
||||||
|
.getChild(new UiSelector().resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/updated_result_item_name"));
|
||||||
|
UiObject result = resultsList.getChild(new UiSelector()
|
||||||
|
.index(i))
|
||||||
|
.getChild(new UiSelector()
|
||||||
|
.resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/updated_result_item_result"));
|
||||||
|
UiObject subResult = resultsList.getChild(new UiSelector()
|
||||||
|
.index(i))
|
||||||
|
.getChild(new UiSelector()
|
||||||
|
.resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/updated_result_item_subresult"));
|
||||||
|
if (testName.waitForExists(500) && result.waitForExists(500) && subResult.waitForExists(500)) {
|
||||||
|
Log.d(TAG, "name: (" + testName.getText() + ") result: (" + result.getText() + ") sub_result: (" + subResult.getText() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ensure we loop over the first screen an extra time once the top of the list has been reached.
|
||||||
|
if (top_of_list){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
top_of_list = !scrollable.scrollBackward(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleTest(String testname) throws Exception {
|
public void toggleTest(String testname) throws Exception {
|
||||||
@ -163,22 +184,4 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
}
|
}
|
||||||
test.click();
|
test.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTestScore(UiScrollable scrollable, UiObject resultsList, String test) throws Exception {
|
|
||||||
if (test.equals("Tessellation")) {
|
|
||||||
scrollable.scrollToEnd(1000);
|
|
||||||
}
|
|
||||||
for (int i=1; i < resultsList.getChildCount(); i++) {
|
|
||||||
UiObject testname = resultsList.getChild(new UiSelector().index(i))
|
|
||||||
.getChild(new UiSelector().resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/updated_result_item_name"));
|
|
||||||
if (testname.exists() && testname.getText().equals(test)) {
|
|
||||||
UiObject result = resultsList.getChild(new UiSelector()
|
|
||||||
.index(i))
|
|
||||||
.getChild(new UiSelector()
|
|
||||||
.resourceId("net.kishonti.gfxbench.gl.v50000.corporate:id/updated_result_item_subresult"));
|
|
||||||
Log.d(TAG, test + " score " + result.getText());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user