Commit b6348170 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Measure max frame interval in GridTabSwitcher animation

Besides frame rate and dirty time span, also measure max frame
interval in the Tab-to-Grid animation.

Bug: 964406
Change-Id: I0e593bcd605b6a0664243ad81db4cfce1f5494bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636585Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664667}
parent 224406f1
...@@ -62,10 +62,13 @@ public class GridTabSwitcherLayout ...@@ -62,10 +62,13 @@ public class GridTabSwitcherLayout
private int mFrameCount; private int mFrameCount;
private long mStartTime; private long mStartTime;
private long mLastFrameTime;
private long mMaxFrameInterval;
private int mStartFrame; private int mStartFrame;
interface PerfListener { interface PerfListener {
void onAnimationDone(int frameRendered, long elapsedMs, int dirtySpan); void onAnimationDone(
int frameRendered, long elapsedMs, long maxFrameInterval, int dirtySpan);
} }
private PerfListener mPerfListenerForTesting; private PerfListener mPerfListenerForTesting;
...@@ -231,6 +234,8 @@ public class GridTabSwitcherLayout ...@@ -231,6 +234,8 @@ public class GridTabSwitcherLayout
}); });
mStartFrame = mFrameCount; mStartFrame = mFrameCount;
mStartTime = SystemClock.elapsedRealtime(); mStartTime = SystemClock.elapsedRealtime();
mLastFrameTime = SystemClock.elapsedRealtime();
mMaxFrameInterval = 0;
mTabToSwitcherAnimation.start(); mTabToSwitcherAnimation.start();
} }
...@@ -296,8 +301,9 @@ public class GridTabSwitcherLayout ...@@ -296,8 +301,9 @@ public class GridTabSwitcherLayout
long lastDirty = mGridTabSwitcher.getLastDirtyTimeForTesting(); long lastDirty = mGridTabSwitcher.getLastDirtyTimeForTesting();
int dirtySpan = (int) (lastDirty - mStartTime); int dirtySpan = (int) (lastDirty - mStartTime);
float fps = 1000.f * frameRendered / elapsedMs; float fps = 1000.f * frameRendered / elapsedMs;
String message = String.format(Locale.US, "fps = %.2f (%d / %dms), dirtySpan = %d", fps, String message = String.format(Locale.US,
frameRendered, elapsedMs, dirtySpan); "fps = %.2f (%d / %dms), maxFrameInterval = %d, dirtySpan = %d", fps, frameRendered,
elapsedMs, mMaxFrameInterval, dirtySpan);
// TODO(crbug.com/964406): stop reporting on Canary before enabling in Finch. // TODO(crbug.com/964406): stop reporting on Canary before enabling in Finch.
if (ChromeVersionInfo.isLocalBuild() || ChromeVersionInfo.isCanaryBuild()) { if (ChromeVersionInfo.isLocalBuild() || ChromeVersionInfo.isCanaryBuild()) {
...@@ -307,7 +313,8 @@ public class GridTabSwitcherLayout ...@@ -307,7 +313,8 @@ public class GridTabSwitcherLayout
} }
if (mPerfListenerForTesting != null) { if (mPerfListenerForTesting != null) {
mPerfListenerForTesting.onAnimationDone(frameRendered, elapsedMs, dirtySpan); mPerfListenerForTesting.onAnimationDone(
frameRendered, elapsedMs, mMaxFrameInterval, dirtySpan);
} }
} }
...@@ -325,5 +332,10 @@ public class GridTabSwitcherLayout ...@@ -325,5 +332,10 @@ public class GridTabSwitcherLayout
? mGridTabSwitcher.getResourceId() ? mGridTabSwitcher.getResourceId()
: 0); : 0);
mFrameCount++; mFrameCount++;
if (mLastFrameTime != 0) {
long elapsed = SystemClock.elapsedRealtime() - mLastFrameTime;
mMaxFrameInterval = Math.max(mMaxFrameInterval, elapsed);
}
mLastFrameTime = SystemClock.elapsedRealtime();
} }
} }
...@@ -153,12 +153,15 @@ public class GridTabSwitcherLayoutPerfTest { ...@@ -153,12 +153,15 @@ public class GridTabSwitcherLayoutPerfTest {
private void reportTabToGridPerf(String fromUrl, String description) private void reportTabToGridPerf(String fromUrl, String description)
throws InterruptedException { throws InterruptedException {
List<Float> frameRates = new LinkedList<>(); List<Float> frameRates = new LinkedList<>();
List<Float> frameInterval = new LinkedList<>();
List<Float> dirtySpans = new LinkedList<>(); List<Float> dirtySpans = new LinkedList<>();
GridTabSwitcherLayout.PerfListener collector = (frameRendered, elapsedMs, dirtySpan) -> { GridTabSwitcherLayout.PerfListener collector =
(frameRendered, elapsedMs, maxFrameInterval, dirtySpan) -> {
assertTrue(elapsedMs assertTrue(elapsedMs
>= GridTabSwitcherLayout.ZOOMING_DURATION * CompositorAnimator.sDurationScale); >= GridTabSwitcherLayout.ZOOMING_DURATION * CompositorAnimator.sDurationScale);
float fps = 1000.f * frameRendered / elapsedMs; float fps = 1000.f * frameRendered / elapsedMs;
frameRates.add(fps); frameRates.add(fps);
frameInterval.add((float) maxFrameInterval);
dirtySpans.add((float) dirtySpan); dirtySpans.add((float) dirtySpan);
}; };
...@@ -189,8 +192,8 @@ public class GridTabSwitcherLayoutPerfTest { ...@@ -189,8 +192,8 @@ public class GridTabSwitcherLayoutPerfTest {
DEFAULT_POLLING_INTERVAL); DEFAULT_POLLING_INTERVAL);
} }
assertEquals(mRepeat, frameRates.size()); assertEquals(mRepeat, frameRates.size());
Log.i(TAG, "%s: fps = %.2f, dirtySpan = %.0f", description, median(frameRates), Log.i(TAG, "%s: fps = %.2f, maxFrameInterval = %.0f, dirtySpan = %.0f", description,
median(dirtySpans)); median(frameRates), median(frameInterval), median(dirtySpans));
} }
private float median(List<Float> list) { private float median(List<Float> list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment