mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-02 19:32:34 +01:00
Add basic instrumentation for call times
- Also, extend UxPerfUiAutomation instead of BaseUiAutomation
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from wlauto import AndroidUiAutoBenchmark, Parameter
|
from wlauto import AndroidUiAutoBenchmark, Parameter
|
||||||
@@ -33,6 +35,8 @@ class SkypeEcho(AndroidUiAutoBenchmark):
|
|||||||
# Skype has no default 'main' activity
|
# Skype has no default 'main' activity
|
||||||
launch_main = False # overrides extended class
|
launch_main = False # overrides extended class
|
||||||
|
|
||||||
|
instrumentation_log = '{}_instrumentation.log'.format(name)
|
||||||
|
|
||||||
parameters = [
|
parameters = [
|
||||||
# Workload parameters go here e.g.
|
# Workload parameters go here e.g.
|
||||||
# Parameter('example_parameter', kind=int, allowed_values=[1,2,3], default=1, override=True, mandatory=False,
|
# Parameter('example_parameter', kind=int, allowed_values=[1,2,3], default=1, override=True, mandatory=False,
|
||||||
@@ -57,6 +61,8 @@ class SkypeEcho(AndroidUiAutoBenchmark):
|
|||||||
|
|
||||||
def __init__(self, device, **kwargs):
|
def __init__(self, device, **kwargs):
|
||||||
super(SkypeEcho, self).__init__(device, **kwargs)
|
super(SkypeEcho, self).__init__(device, **kwargs)
|
||||||
|
self.output_file = os.path.join(self.device.working_directory, self.instrumentation_log)
|
||||||
|
self.uiauto_params['results_file'] = self.output_file
|
||||||
if self.use_gui:
|
if self.use_gui:
|
||||||
self.uiauto_params['my_id'] = self.login_name
|
self.uiauto_params['my_id'] = self.login_name
|
||||||
self.uiauto_params['my_pwd'] = self.login_pass
|
self.uiauto_params['my_pwd'] = self.login_pass
|
||||||
@@ -89,12 +95,33 @@ class SkypeEcho(AndroidUiAutoBenchmark):
|
|||||||
self.device.execute('am force-stop {}'.format(self.package))
|
self.device.execute('am force-stop {}'.format(self.package))
|
||||||
|
|
||||||
def update_result(self, context):
|
def update_result(self, context):
|
||||||
pass
|
self.logger.info('===== update_result() ======')
|
||||||
# super(SkypeEcho, self).update_result(context)
|
super(SkypeEcho, self).update_result(context)
|
||||||
|
# if not self.dumpsys_enabled:
|
||||||
|
# return
|
||||||
|
|
||||||
|
self.device.pull_file(self.output_file, context.output_directory)
|
||||||
|
results_file = os.path.join(context.output_directory, self.instrumentation_log)
|
||||||
|
|
||||||
# process results and add them using
|
# process results and add them using
|
||||||
# context.result.add_metric
|
# context.result.add_metric
|
||||||
|
with open(results_file, 'r') as lines:
|
||||||
|
pattern = r'(?P<key>\w+)\s+(?P<value1>\d+)\s+(?P<value2>\d+)\s+(?P<value3>\d+)'
|
||||||
|
regex = re.compile(pattern)
|
||||||
|
for line in lines:
|
||||||
|
match = regex.search(line)
|
||||||
|
if match:
|
||||||
|
context.result.add_metric((match.group('key') + "_start"), match.group('value1'))
|
||||||
|
context.result.add_metric((match.group('key') + "_finish"), match.group('value2'))
|
||||||
|
context.result.add_metric((match.group('key') + "_duration"), match.group('value3'))
|
||||||
|
|
||||||
def teardown(self, context):
|
def teardown(self, context):
|
||||||
self.logger.info('===== teardown() ======')
|
self.logger.info('===== teardown() ======')
|
||||||
super(SkypeEcho, self).teardown(context)
|
super(SkypeEcho, self).teardown(context)
|
||||||
|
# Pull log files
|
||||||
|
for entry in self.device.listdir(self.device.working_directory):
|
||||||
|
if entry.startswith(self.name) and entry.endswith(".log"):
|
||||||
|
self.device.pull_file(os.path.join(self.device.working_directory, entry),
|
||||||
|
context.output_directory)
|
||||||
|
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||||
# self.device.execute('am force-stop {}'.format(self.package))
|
# self.device.execute('am force-stop {}'.format(self.package))
|
||||||
|
Binary file not shown.
@@ -1,6 +1,11 @@
|
|||||||
package com.arm.wlauto.uiauto.skypeecho;
|
package com.arm.wlauto.uiauto.skypeecho;
|
||||||
|
|
||||||
import java.lang.Runnable;
|
import java.io.File;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -16,9 +21,9 @@ import com.android.uiautomator.core.UiScrollable;
|
|||||||
import com.android.uiautomator.core.UiSelector;
|
import com.android.uiautomator.core.UiSelector;
|
||||||
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
|
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
|
||||||
|
|
||||||
import com.arm.wlauto.uiauto.BaseUiAutomation;
|
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
|
||||||
|
|
||||||
public class UiAutomation extends BaseUiAutomation {
|
public class UiAutomation extends UxPerfUiAutomation {
|
||||||
|
|
||||||
public static String TAG = "uxperf_skypeecho";
|
public static String TAG = "uxperf_skypeecho";
|
||||||
|
|
||||||
@@ -30,7 +35,10 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
public static String endCallButtonResourceId = "com.skype.raider:id/call_end_button";
|
public static String endCallButtonResourceId = "com.skype.raider:id/call_end_button";
|
||||||
public static String noContactMessage = "Could not find contact \"%s\" in the contacts list.";
|
public static String noContactMessage = "Could not find contact \"%s\" in the contacts list.";
|
||||||
|
|
||||||
|
private Map<String, Timer> results = new HashMap<String, Timer>();
|
||||||
|
|
||||||
public void runUiAutomation() throws Exception {
|
public void runUiAutomation() throws Exception {
|
||||||
|
// Get Params
|
||||||
Bundle parameters = getParams();
|
Bundle parameters = getParams();
|
||||||
String loginName = parameters.getString("my_id");
|
String loginName = parameters.getString("my_id");
|
||||||
String loginPass = parameters.getString("my_pwd");
|
String loginPass = parameters.getString("my_pwd");
|
||||||
@@ -38,10 +46,36 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
String contactName = parameters.getString("name").replace("_", " ");
|
String contactName = parameters.getString("name").replace("_", " ");
|
||||||
int callDuration = Integer.parseInt(parameters.getString("duration"));
|
int callDuration = Integer.parseInt(parameters.getString("duration"));
|
||||||
boolean isVideo = "video".equals(parameters.getString("action"));
|
boolean isVideo = "video".equals(parameters.getString("action"));
|
||||||
|
String resultsFile = parameters.getString("results_file");
|
||||||
|
|
||||||
|
// Run tests
|
||||||
|
Timer overallTimer = new Timer();
|
||||||
|
Timer callTimer = new Timer();
|
||||||
|
overallTimer.start();
|
||||||
handleLoginScreen(loginName, loginPass);
|
handleLoginScreen(loginName, loginPass);
|
||||||
selectContact(contactName, contactSkypeid);
|
selectContact(contactName, contactSkypeid);
|
||||||
|
callTimer.start();
|
||||||
makeCall(callDuration, isVideo);
|
makeCall(callDuration, isVideo);
|
||||||
|
callTimer.end();
|
||||||
|
overallTimer.end();
|
||||||
|
|
||||||
|
// Save results
|
||||||
|
results.put("call_test", callTimer);
|
||||||
|
results.put("overall_test", overallTimer);
|
||||||
|
saveResults(results, resultsFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveResults(Map<String, Timer> results, String file) throws Exception {
|
||||||
|
BufferedWriter out = new BufferedWriter(new FileWriter(file));
|
||||||
|
long start, finish, duration;
|
||||||
|
for (Map.Entry<String, Timer> entry : results.entrySet()) {
|
||||||
|
Timer timer = entry.getValue();
|
||||||
|
start = timer.getStart();
|
||||||
|
finish = timer.getFinish();
|
||||||
|
duration = timer.getDuration();
|
||||||
|
out.write(entry.getKey() + " " + start + " " + finish + " " + duration + "\n");
|
||||||
|
}
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectContact(String name, String id) throws Exception {
|
public void selectContact(String name, String id) throws Exception {
|
||||||
@@ -68,8 +102,12 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
UiObject callButton = new UiObject(new UiSelector().descriptionContains(description));
|
UiObject callButton = new UiObject(new UiSelector().descriptionContains(description));
|
||||||
callButton.click();
|
callButton.click();
|
||||||
sleep(duration);
|
sleep(duration);
|
||||||
// TODO Needs to be run on UI thread after sleep
|
// endCall();g
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
// TODO Needs to be run on UI thread after sleep
|
||||||
|
public void endCall() {
|
||||||
final UiObject endButton = getUiObjectByResourceId(endCallButtonResourceId, "android.widget.ImageView");
|
final UiObject endButton = getUiObjectByResourceId(endCallButtonResourceId, "android.widget.ImageView");
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -81,8 +119,8 @@ public class UiAutomation extends BaseUiAutomation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void handleLoginScreen(String username, String password) throws Exception {
|
public void handleLoginScreen(String username, String password) throws Exception {
|
||||||
String useridResoureId = "com.skype.raider:id/sign_in_userid";
|
String useridResoureId = "com.skype.raider:id/sign_in_userid";
|
||||||
|
Reference in New Issue
Block a user