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
private int mFrameCount;
private long mStartTime;
private long mLastFrameTime;
private long mMaxFrameInterval;
private int mStartFrame;
interface PerfListener {
void onAnimationDone(int frameRendered, long elapsedMs, int dirtySpan);
void onAnimationDone(
int frameRendered, long elapsedMs, long maxFrameInterval, int dirtySpan);
}
private PerfListener mPerfListenerForTesting;
......@@ -231,6 +234,8 @@ public class GridTabSwitcherLayout
});
mStartFrame = mFrameCount;
mStartTime = SystemClock.elapsedRealtime();
mLastFrameTime = SystemClock.elapsedRealtime();
mMaxFrameInterval = 0;
mTabToSwitcherAnimation.start();
}
......@@ -296,8 +301,9 @@ public class GridTabSwitcherLayout
long lastDirty = mGridTabSwitcher.getLastDirtyTimeForTesting();
int dirtySpan = (int) (lastDirty - mStartTime);
float fps = 1000.f * frameRendered / elapsedMs;
String message = String.format(Locale.US, "fps = %.2f (%d / %dms), dirtySpan = %d", fps,
frameRendered, elapsedMs, dirtySpan);
String message = String.format(Locale.US,
"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.
if (ChromeVersionInfo.isLocalBuild() || ChromeVersionInfo.isCanaryBuild()) {
......@@ -307,7 +313,8 @@ public class GridTabSwitcherLayout
}
if (mPerfListenerForTesting != null) {
mPerfListenerForTesting.onAnimationDone(frameRendered, elapsedMs, dirtySpan);
mPerfListenerForTesting.onAnimationDone(
frameRendered, elapsedMs, mMaxFrameInterval, dirtySpan);
}
}
......@@ -325,5 +332,10 @@ public class GridTabSwitcherLayout
? mGridTabSwitcher.getResourceId()
: 0);
mFrameCount++;
if (mLastFrameTime != 0) {
long elapsed = SystemClock.elapsedRealtime() - mLastFrameTime;
mMaxFrameInterval = Math.max(mMaxFrameInterval, elapsed);
}
mLastFrameTime = SystemClock.elapsedRealtime();
}
}
......@@ -153,12 +153,15 @@ public class GridTabSwitcherLayoutPerfTest {
private void reportTabToGridPerf(String fromUrl, String description)
throws InterruptedException {
List<Float> frameRates = new LinkedList<>();
List<Float> frameInterval = new LinkedList<>();
List<Float> dirtySpans = new LinkedList<>();
GridTabSwitcherLayout.PerfListener collector = (frameRendered, elapsedMs, dirtySpan) -> {
GridTabSwitcherLayout.PerfListener collector =
(frameRendered, elapsedMs, maxFrameInterval, dirtySpan) -> {
assertTrue(elapsedMs
>= GridTabSwitcherLayout.ZOOMING_DURATION * CompositorAnimator.sDurationScale);
float fps = 1000.f * frameRendered / elapsedMs;
frameRates.add(fps);
frameInterval.add((float) maxFrameInterval);
dirtySpans.add((float) dirtySpan);
};
......@@ -189,8 +192,8 @@ public class GridTabSwitcherLayoutPerfTest {
DEFAULT_POLLING_INTERVAL);
}
assertEquals(mRepeat, frameRates.size());
Log.i(TAG, "%s: fps = %.2f, dirtySpan = %.0f", description, median(frameRates),
median(dirtySpans));
Log.i(TAG, "%s: fps = %.2f, maxFrameInterval = %.0f, dirtySpan = %.0f", description,
median(frameRates), median(frameInterval), median(dirtySpans));
}
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