Skip to content

Commit f29f6d5

Browse files
committed
Jetstream: Adding a workload to execute the
jetstream suite of browser based tests. Jetstream is a browser based benchmark. This workload executes the full suite of Jetstream tests and also includes the addition of the clearChromeTabs function to the base ui automation class.
1 parent 9b19f33 commit f29f6d5

File tree

14 files changed

+617
-0
lines changed

14 files changed

+617
-0
lines changed

wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,26 @@ public void dismissChromePopup() throws Exception {
610610
}
611611
}
612612

613+
// Clear any existing Chrome tabs from the application
614+
public void clearChromeTabs() throws Exception {
615+
UiObject tabselector =
616+
mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/tab_switcher_button")
617+
.className("android.widget.ImageButton"));
618+
if (!tabselector.exists()){
619+
return;
620+
}
621+
tabselector.click();
622+
UiObject menu =
623+
mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/menu_button")
624+
.className("android.widget.ImageButton"));
625+
menu.click();
626+
UiObject closetabs =
627+
mDevice.findObject(new UiSelector().textContains("Close all tabs"));
628+
if (closetabs.exists()){
629+
closetabs.click();
630+
}
631+
}
632+
613633
// Override getParams function to decode a url encoded parameter bundle before
614634
// passing it to workloads.
615635
public Bundle getParams() {

wa/framework/uiauto/uiauto.aar

223 Bytes
Binary file not shown.

wa/workloads/jetstream/__init__.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright 2014-2020 ARM Limited
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
import os
16+
import re
17+
18+
from wa import ApkUiautoWorkload, Parameter
19+
from wa.framework.exception import ValidationError, WorkloadError
20+
21+
class Jetstream(ApkUiautoWorkload):
22+
23+
name = 'jetstream'
24+
package_names = ['com.android.chrome']
25+
regex = re.compile(r'Jetstream Score ([\d.]+)')
26+
tests = ['3d-cube-SP', '3d-raytrace-SP', 'acorn-wtb', 'ai-astar', 'Air', 'async-fs', 'Babylon', 'babylon-wtb', 'base64-SP',
27+
'Basic', 'bomb-workers', 'Box2D', 'cdjs', 'chai-wtb', 'coffeescript-wtb', 'crypto', 'crypto-aes-SP', 'crypto-md5-SP',
28+
'crypto-sha1-SP', 'date-format-tofte-SP', 'date-format-xparb-SP', 'delta-blue', 'earley-boyer','espree-wtb',
29+
'first-inspector-code-load', 'FlightPlanner', 'float-mm.c', 'gaussian-blur', 'gbemu', 'hash-map', 'jshint-wtb',
30+
'json-parse-inspector', 'json-stringify-inspector', 'lebab-wtb', 'mandreel', 'ML', 'multi-inspector-code-load',
31+
'n-body-SP','navier-stokes', 'octane-code-load', 'octane-zlib', 'OfflineAssembler', 'pdfjs', 'prepack-wtb',
32+
'raytrace', 'regex-dna-SP', 'regexp', 'richards', 'segmentation', 'splay', 'stanford-crypto-aes', 'stanford-crypto-pbkdf2',
33+
'stanford-crypto-sha256', 'string-unpack-code-SP', 'tagcloud-SP', 'typescript', 'uglify-js-wtb', 'UniPoker']
34+
description = '''
35+
A workload to execute the jetstream web based benchmark
36+
37+
Test description:
38+
1. Open chrome
39+
2. Navigate to the jetstream website - https://browserbench.org/JetStream/
40+
3. Execute the benchmark
41+
42+
known working chrome version 80.0.3987.149
43+
'''
44+
requires_network = True
45+
46+
def __init__(self, target, **kwargs):
47+
super(Jetstream, self).__init__(target, **kwargs)
48+
self.gui.timeout = 2700
49+
self.regex_tests = []
50+
for test in self.tests:
51+
formatted_string = 'text="([\d.]+)" resource-id="results-cell-({})-score"'.format(test)
52+
self.regex_tests.append(re.compile(formatted_string))
53+
# Add regex for tests with annoyingly different resource id's
54+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="wasm-score-id(gcc-loops-wasm)"'))
55+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="wasm-score-id(HashSet-wasm)"'))
56+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="wasm-score-id(quicksort-wasm)"'))
57+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="wasm-score-id(richards-wasm)"'))
58+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="wasm-score-id(tsf-wasm)"'))
59+
self.regex_tests.append(re.compile(r'text="([\d.]+)" resource-id="(wsl)-score-score"'))
60+
61+
def extract_results(self, context):
62+
self.target.execute('uiautomator dump')
63+
self.target.pull(os.path.join('/sdcard/window_dump.xml'), os.path.join(context.output_directory, 'screenDump.xml'))
64+
65+
def update_output(self, context):
66+
super(Jetstream, self).update_output(context)
67+
screen_xml = os.path.join(context.output_directory, 'screenDump.xml')
68+
total_score_regex = re.compile(r'text="([\d.]+)" resource-id=""')
69+
with open(screen_xml, 'r') as fh:
70+
xml_str = fh.read()
71+
total_score_match = total_score_regex.search(xml_str)
72+
if total_score_match:
73+
total_score = float(total_score_match.group(1))
74+
context.add_metric('jetstream', total_score, 'score', lower_is_better=False)
75+
else:
76+
raise WorkloadError('Total score for jetstream could not be found')
77+
for regex in self.regex_tests:
78+
match = regex.search(xml_str)
79+
if match:
80+
result = float(match.group(1))
81+
test_name = match.group(2)
82+
context.add_metric(test_name, result, 'score', lower_is_better=False)
83+
else:
84+
raise WorkloadError('score {} cannot be found'.format(regex))
259 KB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apply plugin: 'com.android.application'
2+
3+
def packageName = "com.arm.wa.uiauto.jetstream"
4+
5+
android {
6+
compileSdkVersion 28
7+
buildToolsVersion "28.0.3"
8+
defaultConfig {
9+
applicationId "${packageName}"
10+
minSdkVersion 18
11+
targetSdkVersion 28
12+
versionCode 1
13+
versionName "1.0"
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
}
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
applicationVariants.all { variant ->
22+
variant.outputs.each { output ->
23+
output.outputFile = file("$project.buildDir/apk/${packageName}.apk")
24+
}
25+
}
26+
}
27+
}
28+
29+
dependencies {
30+
compile fileTree(dir: 'libs', include: ['*.jar'])
31+
compile 'com.android.support.test:runner:0.5'
32+
compile 'com.android.support.test:rules:0.5'
33+
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
34+
compile(name: 'uiauto', ext:'aar')
35+
}
36+
37+
repositories {
38+
flatDir {
39+
dirs 'libs'
40+
}
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.arm.wa.uiauto.jetstream"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
8+
<instrumentation
9+
android:name="android.support.test.runner.AndroidJUnitRunner"
10+
android:targetPackage="${applicationId}"/>
11+
12+
</manifest>
13+
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/* Copyright 2014-2018 ARM Limited
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
package com.arm.wa.uiauto.jetstream;
17+
18+
import android.os.Bundle;
19+
import android.support.test.runner.AndroidJUnit4;
20+
import android.support.test.uiautomator.UiObject;
21+
import android.support.test.uiautomator.UiObjectNotFoundException;
22+
import android.support.test.uiautomator.UiSelector;
23+
import android.support.test.uiautomator.UiScrollable;
24+
25+
import com.arm.wa.uiauto.BaseUiAutomation;
26+
import android.util.Log;
27+
28+
import org.junit.Before;
29+
import org.junit.Test;
30+
import org.junit.runner.RunWith;
31+
32+
import java.util.concurrent.TimeUnit;
33+
34+
@RunWith(AndroidJUnit4.class)
35+
public class UiAutomation extends BaseUiAutomation {
36+
37+
private int networkTimeoutSecs = 30;
38+
private long networkTimeout = TimeUnit.SECONDS.toMillis(networkTimeoutSecs);
39+
public static String TAG = "UXPERF";
40+
41+
@Before
42+
public void initialize(){
43+
initialize_instrumentation();
44+
}
45+
46+
@Test
47+
public void setup() throws Exception{
48+
setScreenOrientation(ScreenOrientation.NATURAL);
49+
dismissChromePopup();
50+
openJetstream();
51+
}
52+
53+
@Test
54+
public void runWorkload() throws Exception {
55+
runBenchmark();
56+
}
57+
58+
@Test
59+
public void teardown() throws Exception{
60+
clearChromeTabs();
61+
unsetScreenOrientation();
62+
}
63+
64+
public void runBenchmark() throws Exception {
65+
UiObject start =
66+
mDevice.findObject(new UiSelector().description("Start Test"));
67+
68+
UiObject starttext =
69+
mDevice.findObject(new UiSelector().text("Start Test"));
70+
71+
// Run Jetstream test
72+
if (start.waitForExists(20000)) {
73+
start.click();
74+
} else {
75+
starttext.click();
76+
}
77+
78+
UiObject scores =
79+
mDevice.findObject(new UiSelector().resourceId("result-summary"));
80+
scores.waitForExists(2100000);
81+
}
82+
83+
public void openJetstream() throws Exception {
84+
UiObject urlBar =
85+
mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/url_bar"));
86+
87+
UiObject searchBox = mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/search_box_text"));
88+
89+
if (!urlBar.waitForExists(5000)) {
90+
searchBox.click();
91+
}
92+
93+
String url = "http://browserbench.org/JetStream/";
94+
95+
// Clicking search box turns it into url bar on some deivces
96+
if(urlBar.waitForExists(2000)) {
97+
urlBar.click();
98+
sleep(2);
99+
urlBar.setText(url);
100+
} else {
101+
searchBox.setText(url);
102+
}
103+
pressEnter();
104+
}
105+
106+
/*public void clearTabs() throws Exception {
107+
UiObject tabselector =
108+
mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/tab_switcher_button")
109+
.className("android.widget.ImageButton"));
110+
if (!tabselector.exists()){
111+
return;
112+
}
113+
tabselector.click();
114+
UiObject menu =
115+
mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/menu_button")
116+
.className("android.widget.ImageButton"));
117+
menu.click();
118+
UiObject closetabs =
119+
mDevice.findObject(new UiSelector().textContains("Close all tabs"));
120+
if (closetabs.exists()){
121+
closetabs.click();
122+
}
123+
}*/
124+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:2.3.2'
9+
10+
// NOTE: Do not place your application dependencies here; they belong
11+
// in the individual module build.gradle files
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
jcenter()
18+
}
19+
}
20+
21+
task clean(type: Delete) {
22+
delete rootProject.buildDir
23+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Copyright 2018 ARM Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
18+
# CD into build dir if possible - allows building from any directory
19+
script_path='.'
20+
if `readlink -f $0 &>/dev/null`; then
21+
script_path=`readlink -f $0 2>/dev/null`
22+
fi
23+
script_dir=`dirname $script_path`
24+
cd $script_dir
25+
26+
# Ensure gradelw exists before starting
27+
if [[ ! -f gradlew ]]; then
28+
echo 'gradlew file not found! Check that you are in the right directory.'
29+
exit 9
30+
fi
31+
32+
# Copy base class library from wa dist
33+
libs_dir=app/libs
34+
base_class=`python3 -c "import os, wa; print(os.path.join(os.path.dirname(wa.__file__), 'framework', 'uiauto', 'uiauto.aar'))"`
35+
mkdir -p $libs_dir
36+
cp $base_class $libs_dir
37+
38+
# Build and return appropriate exit code if failed
39+
# gradle build
40+
./gradlew clean :app:assembleDebug
41+
exit_code=$?
42+
if [[ $exit_code -ne 0 ]]; then
43+
echo "ERROR: 'gradle build' exited with code $exit_code"
44+
exit $exit_code
45+
fi
46+
47+
# If successful move APK file to workload folder (overwrite previous)
48+
package=com.arm.wa.uiauto.jetstream
49+
rm -f ../$package
50+
if [[ -f app/build/apk/$package.apk ]]; then
51+
cp app/build/apk/$package.apk ../$package.apk
52+
else
53+
echo 'ERROR: UiAutomator apk could not be found!'
54+
exit 9
55+
fi
52.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)