diff options
author | Allen Hair <allenhair@google.com> | 2014-05-22 19:24:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-22 19:24:02 +0000 |
commit | 368e07fbc3863e60dce536b73441ad5439ea94c6 (patch) | |
tree | 0ad8b43f5acf799f33e64b31b56c8a3fcb96c7bb | |
parent | 022c4b8bd20c654405470a72443fafaa08838adb (diff) | |
parent | 5414dc94ce21f5d142d4d3f0b60841fdfdafeb3c (diff) | |
download | janktesthelper-368e07fbc3863e60dce536b73441ad5439ea94c6.tar.gz |
Merge "Handle fenced frames that have not been presented."
-rw-r--r-- | src/android/support/test/jank/JankResult.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/android/support/test/jank/JankResult.java b/src/android/support/test/jank/JankResult.java index a5a1eb4..71e595c 100644 --- a/src/android/support/test/jank/JankResult.java +++ b/src/android/support/test/jank/JankResult.java @@ -16,6 +16,7 @@ package android.support.test.jank; +import android.util.Log; import android.view.FrameStats; /** A {@link JankResult} contains the results of a jank monitoring session. This includes the number @@ -23,6 +24,8 @@ import android.view.FrameStats; * as the nomalized longest frame time.*/ public class JankResult { + private static final String TAG = JankResult.class.getSimpleName(); + // Maximum normalized error in frame duration before the frame is considered janky private static final double MAX_ERROR = 0.5f; // Maximum normalized frame duration before the frame is considered a pause @@ -51,7 +54,13 @@ public class JankResult { long totalDuration = 0; // Skip first frame for (int i = 2; i < frameCount; i++) { - // TODO: Handle fenced frames that have not been presented. Either skip or throw. + // Handle frames that have not been presented. + if (stats.getFramePresentedTimeNano(i) == -1) { + // The animation must not have completed. Warn and break out of the loop. + Log.w(TAG, "Skipping fenced frame."); + frameCount = i; + break; + } long frameDuration = stats.getFramePresentedTimeNano(i) - stats.getFramePresentedTimeNano(i - 1); double normalized = (double)frameDuration / refreshPeriod; |