mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00:00 
			
		
		
		
	Androbench: Migrating to WA3 and modifying to extract results instead of taking a screenshot
This commit is contained in:
		
							
								
								
									
										55
									
								
								wa/workloads/androbench/__init__.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										55
									
								
								wa/workloads/androbench/__init__.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,55 @@ | |||||||
|  | #    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 re | ||||||
|  |  | ||||||
|  | from wa import ApkUiautoWorkload | ||||||
|  |  | ||||||
|  | class Androbench(ApkUiautoWorkload): | ||||||
|  |  | ||||||
|  |     name = 'androbench' | ||||||
|  |     package_names = ['com.andromeda.androbench2'] | ||||||
|  |     regex_matches = [re.compile(r'Sequential Read Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'Sequential Write Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'Random Read Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'Random Write Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'SQL Insert Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'SQL Update Score ([\d.]+)'), | ||||||
|  |                      re.compile(r'SQL Delete Score ([\d.]+)')] | ||||||
|  |     description = ''' | ||||||
|  |     Executes storage performance benchmarks | ||||||
|  |  | ||||||
|  |     The Androbench workflow carries out the following typical productivity tasks. | ||||||
|  |     1. Open Androbench application | ||||||
|  |     2. Execute all memory benchmarks | ||||||
|  |  | ||||||
|  |     Known working APK version: 5.0.1 | ||||||
|  |     ''' | ||||||
|  |  | ||||||
|  |     def update_output(self, context): | ||||||
|  |         super(Androbench, self).update_output(context) | ||||||
|  |         expected_results = len(self.regex_matches) | ||||||
|  |         logcat_file = context.get_artifact_path('logcat') | ||||||
|  |         with open(logcat_file) as fh: | ||||||
|  |             for line in fh:  | ||||||
|  |                 for regex in self.regex_matches: | ||||||
|  |                     match = regex.search(line) | ||||||
|  |                     if match:  | ||||||
|  |                         result = float(match.group(1)) | ||||||
|  |                         entry = regex.pattern.rsplit(None, 1)[0] | ||||||
|  |                         context.add_metric(entry, result, 'MB/s', lower_is_better=False) | ||||||
|  |                         expected_results -= 1 | ||||||
|  |         if expected_results > 0: | ||||||
|  |             raise WorkloadError("The Androbench workload has failed. Expected {} scores, Detected {} scores." | ||||||
|  |             .format(len(self.regex_matches), expected_results)) | ||||||
							
								
								
									
										
											BIN
										
									
								
								wa/workloads/androbench/com.arm.wa.uiauto.androbench.apk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								wa/workloads/androbench/com.arm.wa.uiauto.androbench.apk
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -0,0 +1,99 @@ | |||||||
|  | /*    Copyright 2013-2015 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.androbench; | ||||||
|  |  | ||||||
|  | import android.app.Activity; | ||||||
|  | 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 android.support.test.uiautomator.UiScrollable; | ||||||
|  | import android.view.KeyEvent; | ||||||
|  | import android.util.Log; | ||||||
|  |  | ||||||
|  | import com.arm.wa.uiauto.BaseUiAutomation; | ||||||
|  |  | ||||||
|  | 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 { | ||||||
|  |  | ||||||
|  |     public static String TAG = "UXPERF"; | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void runWorkload() throws Exception { | ||||||
|  |         runBenchmark(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void extractResults() throws Exception { | ||||||
|  |         getScores(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void runBenchmark() throws Exception { | ||||||
|  |         UiSelector selector = new UiSelector(); | ||||||
|  |         UiObject btn_microbench = mDevice.findObject(selector.textContains("Micro") | ||||||
|  |                                                      .className("android.widget.Button")); | ||||||
|  |         if (btn_microbench.exists()) { | ||||||
|  |             btn_microbench.click(); | ||||||
|  |         } else { | ||||||
|  |             UiObject bench = | ||||||
|  |                 mDevice.findObject(new UiSelector().resourceIdMatches("com.andromeda.androbench2:id/btnStartingBenchmarking")); | ||||||
|  |                 bench.click(); | ||||||
|  |         } | ||||||
|  |         UiObject btn_yes= mDevice.findObject(selector.textContains("Yes") | ||||||
|  |                                                      .className("android.widget.Button")); | ||||||
|  |         btn_yes.click(); | ||||||
|  |  | ||||||
|  |         UiObject complete_text = mDevice.findObject(selector.text("Cancel") | ||||||
|  |                                                         .className("android.widget.Button")); | ||||||
|  |         waitObject(complete_text); | ||||||
|  |         sleep(2); | ||||||
|  |         complete_text.click(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void getScores() throws Exception { | ||||||
|  |         UiSelector selector = new UiSelector(); | ||||||
|  |         UiObject seqRead =  | ||||||
|  |             mDevice.findObject(selector.text("Sequential Read").fromParent(selector.index(1))); | ||||||
|  |         UiObject seqWrite =  | ||||||
|  |             mDevice.findObject(selector.text("Sequential Write").fromParent(selector.index(1))); | ||||||
|  |         UiObject ranRead =  | ||||||
|  |             mDevice.findObject(selector.text("Random Read").fromParent(selector.index(1))); | ||||||
|  |         UiObject ranWrite =  | ||||||
|  |             mDevice.findObject(selector.text("Random Write").fromParent(selector.index(1))); | ||||||
|  |         UiObject sqlInsert =  | ||||||
|  |             mDevice.findObject(selector.text("SQLite Insert").fromParent(selector.index(1))); | ||||||
|  |         UiObject sqlUpdate =  | ||||||
|  |             mDevice.findObject(selector.text("SQLite Update").fromParent(selector.index(1))); | ||||||
|  |         UiObject sqlDelete =  | ||||||
|  |             mDevice.findObject(selector.text("SQLite Delete").fromParent(selector.index(1))); | ||||||
|  |         Log.d(TAG, "Sequential Read Score " + seqRead.getText()); | ||||||
|  |         Log.d(TAG, "Sequential Write Score " + seqWrite.getText()); | ||||||
|  |         Log.d(TAG, "Random Read Score " + ranRead.getText()); | ||||||
|  |         Log.d(TAG, "Random Write Score " + ranWrite.getText()); | ||||||
|  |         Log.d(TAG, "SQL Insert Score " + sqlInsert.getText()); | ||||||
|  |         Log.d(TAG, "SQL Update Score " + sqlUpdate.getText()); | ||||||
|  |         Log.d(TAG, "SQL Delete Score " + sqlDelete.getText()); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user