diff options
| author | 2018-09-28 14:57:13 -0700 | |
|---|---|---|
| committer | 2018-09-28 15:03:55 -0700 | |
| commit | 017cddcbcb555b8e0a7a046da08156ca5453e77e (patch) | |
| tree | 764d1e055fc89162b6b5e9135e498609c7c205b2 | |
| parent | 132ee83808ddc2b4ef547d182f6261ca34646599 (diff) | |
AM: Update WaitResult parsing logic in AppLaunch
thisTime is no longer printed out when running am start -W
Remove dependencies with line number when parsing output
Bug: 67683350
Test: atest google/perf/app-startup/third-party-apps/cold-dropcache-stable-test -v
Test: check applaunch.txt matches test run
Change-Id: Ie39486a1552d1a35c621a4ff67d7043d55a19e10
| -rw-r--r-- | tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java index 4a6fe49f2676..debe7b4be1d0 100644 --- a/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java +++ b/tests/AppLaunch/src/com/android/tests/applaunch/AppLaunch.java @@ -106,9 +106,8 @@ public class AppLaunch extends InstrumentationTestCase { private static final String DROP_CACHE_SCRIPT = "/data/local/tmp/dropCache.sh"; private static final String APP_LAUNCH_CMD = "am start -W -n"; private static final String SUCCESS_MESSAGE = "Status: ok"; - private static final String WARNING_MESSAGE = "Warning:"; + private static final String TOTAL_TIME_MESSAGE = "TotalTime:"; private static final String COMPILE_SUCCESS = "Success"; - private static final String THIS_TIME = "ThisTime:"; private static final String LAUNCH_ITERATION = "LAUNCH_ITERATION - %d"; private static final String TRACE_ITERATION = "TRACE_ITERATION-%d"; private static final String LAUNCH_ITERATION_PREFIX = "LAUNCH_ITERATION"; @@ -808,15 +807,13 @@ public class AppLaunch extends InstrumentationTestCase { String launchTime = "-1"; String cpuCycles = "-1"; String majorFaults = "-1"; - boolean coldLaunchSuccess = false; - boolean hotLaunchSuccess = false; + boolean launchSuccess = false; try { InputStream inputStream = new FileInputStream(parcelDesc.getFileDescriptor()); /* SAMPLE OUTPUT : Cold launch Starting: Intent { cmp=com.google.android.calculator/com.android.calculator2.Calculator } Status: ok Activity: com.google.android.calculator/com.android.calculator2.Calculator - ThisTime: 357 TotalTime: 357 WaitTime: 377 Complete*/ @@ -825,7 +822,6 @@ public class AppLaunch extends InstrumentationTestCase { Warning: Activity not started, its current task has been brought to the front Status: ok Activity: com.google.android.calculator/com.android.calculator2.CalculatorGoogle - ThisTime: 60 TotalTime: 60 WaitTime: 67 Complete*/ @@ -836,54 +832,37 @@ public class AppLaunch extends InstrumentationTestCase { Total test time,1.462129,seconds,*/ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( inputStream)); - String line = null; - int lineCount = 1; + String line; mBufferedWriter.newLine(); mBufferedWriter.write(headerInfo); mBufferedWriter.newLine(); while ((line = bufferedReader.readLine()) != null) { - if (lineCount == 2 && line.startsWith(SUCCESS_MESSAGE)) { - coldLaunchSuccess = true; + mBufferedWriter.write(line); + mBufferedWriter.newLine(); + if (line.startsWith(SUCCESS_MESSAGE)) { + launchSuccess = true; } - if (lineCount == 2 && line.startsWith(WARNING_MESSAGE)) { - hotLaunchSuccess = true; + if (!launchSuccess) { + continue; } // Parse TotalTime which is the launch time - if (coldLaunchSuccess && lineCount == 5) { - String launchSplit[] = line.split(":"); - launchTime = launchSplit[1].trim(); - } - if (hotLaunchSuccess && lineCount == 6) { + if (line.startsWith(TOTAL_TIME_MESSAGE)) { String launchSplit[] = line.split(":"); launchTime = launchSplit[1].trim(); } if (mSimplePerfAppOnly) { - // Parse simpleperf output. - if ((lineCount == 9 && coldLaunchSuccess) - || (lineCount == 10 && hotLaunchSuccess)) { - if (!line.contains("cpu-cycles")) { - Log.e(TAG, "Error in simpleperf output"); - } else { - cpuCycles = line.split(",")[0].trim(); - } - } else if ((lineCount == 10 && coldLaunchSuccess) - || (lineCount == 11 && hotLaunchSuccess)) { - if (!line.contains("major-faults")) { - Log.e(TAG, "Error in simpleperf output"); - } else { - majorFaults = line.split(",")[0].trim(); - } + if (line.contains(",cpu-cycles,")) { + cpuCycles = line.split(",")[0].trim(); + } else if (line.contains(",major-faults,")) { + majorFaults = line.split(",")[0].trim(); } } - mBufferedWriter.write(line); - mBufferedWriter.newLine(); - lineCount++; } mBufferedWriter.flush(); inputStream.close(); } catch (IOException e) { - Log.w(TAG, "Error writing the launch file", e); + Log.w(TAG, "Error parsing launch time and writing to file", e); } return new AppLaunchResult(launchTime, cpuCycles, majorFaults); } |