Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3de2b2e1 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Wait for broadcast queue to become idle between test runs

Test: bit MultiUserPerfTests:android.multiuser.UserLifecycleTests
Bug: 64165549
Change-Id: I593885d737fab1ef717a166f6219129809ccfd99
parent 3aa4caab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -20,7 +20,8 @@ LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_STATIC_JAVA_LIBRARIES := \
    android-support-test
    android-support-test \
    ub-uiautomator

LOCAL_PACKAGE_NAME := MultiUserPerfTests

+10 −3
Original line number Diff line number Diff line
@@ -17,13 +17,16 @@ package android.multiuser;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.test.InstrumentationRegistry;
import android.support.test.uiautomator.UiDevice;

import java.io.IOException;
import java.util.ArrayList;

// Based on //platform/frameworks/base/apct-tests/perftests/utils/BenchmarkState.java
public class BenchmarkRunner {

    private static long COOL_OFF_PERIOD_MS = 2000;
    private static final long COOL_OFF_PERIOD_MS = 1000;

    private static final int NUM_ITERATIONS = 4;

@@ -70,9 +73,13 @@ public class BenchmarkRunner {
    }

    private void prepareForNextRun() {
        // TODO: Once http://b/63115387 is fixed, look into using "am wait-for-broadcast-idle"
        // command instead of waiting for a fixed amount of time.
        SystemClock.sleep(COOL_OFF_PERIOD_MS);
        try {
            UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
                    .executeShellCommand("am wait-for-broadcast-idle");
        } catch (IOException e) {
            throw new IllegalStateException("Cannot execute shell command", e);
        }
        mStartTimeNs = System.nanoTime();
        mPausedDurationNs = 0;
    }