Merge "Settings performance testing" am: cd85c64362
am: d6d12e558c
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1318235 Change-Id: I599a60ac2cb6bf475017ef66252df2e9c960829b
This commit is contained in:
@@ -62,6 +62,7 @@ public class LaunchSettingsTest {
|
|||||||
private static final int TEST_TIME = 10;
|
private static final int TEST_TIME = 10;
|
||||||
private static final Pattern PATTERN = Pattern.compile("TotalTime:\\s[0-9]*");
|
private static final Pattern PATTERN = Pattern.compile("TotalTime:\\s[0-9]*");
|
||||||
private static final Page[] PAGES;
|
private static final Page[] PAGES;
|
||||||
|
private static final String TAG = "SettingsPerfTests";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
PAGES = new Page[]{
|
PAGES = new Page[]{
|
||||||
@@ -144,11 +145,17 @@ public class LaunchSettingsTest {
|
|||||||
private void putResultToBundle() {
|
private void putResultToBundle() {
|
||||||
for (String string : mResult.keySet()) {
|
for (String string : mResult.keySet()) {
|
||||||
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "max"),
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "max"),
|
||||||
getMax(mResult.get(string)));
|
getMax(string));
|
||||||
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "min"),
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "min"),
|
||||||
getMin(mResult.get(string)));
|
getMin(string));
|
||||||
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "avg"),
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "avg"),
|
||||||
getAvg(mResult.get(string)));
|
getAvg(string));
|
||||||
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "25 Percentile"),
|
||||||
|
getPercentile(string, 25));
|
||||||
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "50 Percentile"),
|
||||||
|
getPercentile(string, 50));
|
||||||
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "75 Percentile"),
|
||||||
|
getPercentile(string, 75));
|
||||||
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "all_results"),
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "all_results"),
|
||||||
mResult.get(string).toString());
|
mResult.get(string).toString());
|
||||||
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "results_count"),
|
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "results_count"),
|
||||||
@@ -156,16 +163,30 @@ public class LaunchSettingsTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMax(ArrayList<Integer> launchResult) {
|
private String getMax(String page) {
|
||||||
return String.format("%s", launchResult.isEmpty() ? "null" : Collections.max(launchResult));
|
if (mResult.get(page).size() == TEST_TIME) {
|
||||||
|
return String.format("%s", Collections.max(mResult.get(page)));
|
||||||
|
}
|
||||||
|
Log.e(TAG, String.format("Fail to get max of %s.", page));
|
||||||
|
return "0";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMin(ArrayList<Integer> launchResult) {
|
private String getMin(String page) {
|
||||||
return String.format("%s", launchResult.isEmpty() ? "null" : Collections.min(launchResult));
|
if (mResult.get(page).size() == TEST_TIME) {
|
||||||
|
return String.format("%s", Collections.min(mResult.get(page)));
|
||||||
|
}
|
||||||
|
Log.e(TAG, String.format("Fail to get min of %s.", page));
|
||||||
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAvg(ArrayList<Integer> launchResult) {
|
private String getAvg(String page) {
|
||||||
return String.valueOf((int) launchResult.stream().mapToInt(i -> i).average().orElse(0));
|
if (mResult.get(page).size() == TEST_TIME) {
|
||||||
|
return String.valueOf((int) mResult.get(page).stream().mapToInt(
|
||||||
|
i -> i).average().orElse(0));
|
||||||
|
}
|
||||||
|
Log.e(TAG, String.format("Fail to get avg of %s.", page));
|
||||||
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScreenTimeOut(String timeout) throws Exception {
|
private void setScreenTimeOut(String timeout) throws Exception {
|
||||||
@@ -202,4 +223,14 @@ public class LaunchSettingsTest {
|
|||||||
private String getAirplaneModeStatus() throws Exception {
|
private String getAirplaneModeStatus() throws Exception {
|
||||||
return mDevice.executeShellCommand("settings get global airplane_mode_on");
|
return mDevice.executeShellCommand("settings get global airplane_mode_on");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPercentile(String page, double position) {
|
||||||
|
Collections.sort(mResult.get(page));
|
||||||
|
if (mResult.get(page).size() == TEST_TIME) {
|
||||||
|
return String.valueOf(
|
||||||
|
mResult.get(page).get((int) (Math.ceil(TEST_TIME * position / 100)) - 1));
|
||||||
|
}
|
||||||
|
Log.e(TAG, String.format("Fail to get percentile of %s.", page));
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user