From 9ba705609f019eafe1ca16fe5c02d50006416f9b Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 27 Jul 2021 15:05:29 +0800 Subject: [PATCH] Add interval for relayout perf test So if there are messages posted to other threads in relayout, they won't affect the next round to execute relayout. And the continuous invocation isn't common in the real case. Bug: 129527548 Test: atest RelayoutPerfTest Change-Id: I0081fc7a80271ee3dd97c19a6ae7e3bc13ae8a8b --- .../windowmanager/src/android/wm/RelayoutPerfTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java index 1be68f5d53a44..44e6c702fd90e 100644 --- a/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java +++ b/apct-tests/perftests/windowmanager/src/android/wm/RelayoutPerfTest.java @@ -22,6 +22,7 @@ import android.app.Activity; import android.content.Context; import android.graphics.Point; import android.os.RemoteException; +import android.os.SystemClock; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfTestActivity; @@ -124,6 +125,12 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase } private static class RelayoutRunner { + /** + * There may be some messages post to other threads with holding WM lock after relayout. + * Let it take a break to avoid lock contention that isn't the scope of this test. + */ + private static final long INTERVAL_MS = 10; + final ClientWindowFrames mOutFrames = new ClientWindowFrames(); final MergedConfiguration mOutMergedConfiguration = new MergedConfiguration(); final InsetsState mOutInsetsState = new InsetsState(); @@ -158,6 +165,9 @@ public class RelayoutPerfTest extends WindowManagerPerfTestBase mViewVisibility.getAsInt(), mFlags, mFrameNumber, mOutFrames, mOutMergedConfiguration, mOutSurfaceControl, mOutInsetsState, mOutControls, mOutSurfaceSize); + state.pauseTiming(); + SystemClock.sleep(INTERVAL_MS); + state.resumeTiming(); } } }