aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscott <scott.jackson@arm.com>2018-02-27 10:55:13 +0000
committerMarc Bonnici <marc.bonnici@arm.com>2018-03-08 10:16:02 +0000
commit87541c647a6da2227e94fd97648b9b5961ff08f8 (patch)
treec5c1efe45ebf9234c675eaae73daf705fcdb7a1d
parente82fa488265b451c723fd573796f2760ad6f80ff (diff)
Speedometer: Creating a wa3 speedometer workload
-rwxr-xr-xwa/workloads/speedometer/__init__.py60
-rwxr-xr-xwa/workloads/speedometer/com.arm.wa.uiauto.speedometer.apkbin0 -> 263619 bytes
-rwxr-xr-xwa/workloads/speedometer/uiauto/app/src/main/java/com/arm/wa/uiauto/speedometer/UiAutomation.java98
3 files changed, 158 insertions, 0 deletions
diff --git a/wa/workloads/speedometer/__init__.py b/wa/workloads/speedometer/__init__.py
new file mode 100755
index 00000000..66b06d1d
--- /dev/null
+++ b/wa/workloads/speedometer/__init__.py
@@ -0,0 +1,60 @@
+# Copyright 2014-2016 ARM Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import os
+import re
+
+from wa import UiautoWorkload, Parameter
+from wa.framework.exception import ValidationError
+from wa.utils.types import list_of_strs
+from wa.utils.misc import unique
+
+
+class Speedometer(UiautoWorkload):
+
+ name = 'speedometer'
+ regex=re.compile(r'Speedometer Score ([\d.]+)')
+ description = '''
+ A workload to execute the speedometer web based benchmark
+
+ Test description:
+ 1. Open browser application
+ 2. Navigate to the speedometer website - http://browserbench.org/Speedometer/
+ 3. Execute the benchmark
+
+ '''
+
+ def __init__(self, target, **kwargs):
+ super(Speedometer, self).__init__(target, **kwargs)
+ self.gui.timeout = 1500
+
+ def setup(self, context):
+ super(Speedometer, self).setup(context)
+ self.target.execute('am start -a android.intent.action.VIEW -d http://browserbench.org/Speedometer/')
+
+ def update_output(self, context):
+ super(Speedometer, self).update_output(context)
+ result = None
+ logcat_file = context.get_artifact_path('logcat')
+ with open(logcat_file) as fh:
+ for line in fh:
+ match = self.regex.search(line)
+ if match:
+ result = float(match.group(1))
+
+ if result is not None:
+ context.add_metric('Speedometer Score', result, 'Runs per minute', lower_is_better=False)
+ else:
+ raise WorkloadError("The Speedometer workload has failed. No score was obtainable.")
+
diff --git a/wa/workloads/speedometer/com.arm.wa.uiauto.speedometer.apk b/wa/workloads/speedometer/com.arm.wa.uiauto.speedometer.apk
new file mode 100755
index 00000000..23d1449a
--- /dev/null
+++ b/wa/workloads/speedometer/com.arm.wa.uiauto.speedometer.apk
Binary files differ
diff --git a/wa/workloads/speedometer/uiauto/app/src/main/java/com/arm/wa/uiauto/speedometer/UiAutomation.java b/wa/workloads/speedometer/uiauto/app/src/main/java/com/arm/wa/uiauto/speedometer/UiAutomation.java
new file mode 100755
index 00000000..9a87a7cd
--- /dev/null
+++ b/wa/workloads/speedometer/uiauto/app/src/main/java/com/arm/wa/uiauto/speedometer/UiAutomation.java
@@ -0,0 +1,98 @@
+/* Copyright 2014-2016 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.arm.wa.uiauto.speedometer;
+
+import android.os.Bundle;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiObjectNotFoundException;
+import android.support.test.uiautomator.UiSelector;
+
+import com.arm.wa.uiauto.BaseUiAutomation;
+import android.util.Log;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeUnit;
+
+@RunWith(AndroidJUnit4.class)
+public class UiAutomation extends BaseUiAutomation {
+
+ private int networkTimeoutSecs = 30;
+ private long networkTimeout = TimeUnit.SECONDS.toMillis(networkTimeoutSecs);
+ public static String TAG = "UXPERF";
+ public boolean textenabled = false;
+
+ @Before
+ public void initialize(){
+ initialize_instrumentation();
+ }
+
+ @Test
+ public void setup() throws Exception{
+ setScreenOrientation(ScreenOrientation.NATURAL);
+ clearFirstRun();
+ }
+
+ @Test
+ public void runWorkload() throws Exception {
+ runBenchmark();
+ }
+
+ @Test
+ public void teardown() throws Exception{
+ unsetScreenOrientation();
+ }
+
+ public void clearFirstRun() throws Exception {
+ UiObject accept =
+ mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/terms_accept")
+ .className("android.widget.Button"));
+ if (accept.exists()){
+ accept.click();
+ UiObject negative =
+ mDevice.findObject(new UiSelector().resourceId("com.android.chrome:id/negative_button")
+ .className("android.widget.Button"));
+ negative.waitForExists(100000);
+ negative.click();
+ }
+ }
+
+ public void runBenchmark() throws Exception {
+ UiObject start =
+ mDevice.findObject(new UiSelector().description("Start Test")
+ .className("android.widget.Button"));
+ if (start.exists()){
+ start.click();
+ } else {
+ UiObject starttext =
+ mDevice.findObject(new UiSelector().text("Start Test")
+ .className("android.widget.Button"));
+ starttext.click();
+ }
+ UiObject scores =
+ mDevice.findObject(new UiSelector().resourceId("result-number")
+ .className("android.view.View"));
+ scores.waitForExists(2100000);
+ String textScore = scores.getText();
+ Log.d(TAG, "Speedometer Score " + textScore);
+ Log.d(TAG, "Speedometer Score " + scores.getContentDescription());
+ }
+}
+