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

Commit 156315ce authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Change perf tests to have less deviation."

parents b103b8b3 eed98a60
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ public final class JobStore {
    @VisibleForTesting
    public static JobStore initAndGetForTesting(Context context, File dataDir) {
        JobStore jobStoreUnderTest = new JobStore(context, new Object(), dataDir);
        jobStoreUnderTest.clear();
        jobStoreUnderTest.clearForTesting();
        return jobStoreUnderTest;
    }

@@ -222,6 +222,14 @@ public final class JobStore {
        return replaced;
    }

    /**
     * The same as above but does not schedule writing. This makes perf benchmarks more stable.
     */
    @VisibleForTesting
    public void addForTesting(JobStatus jobStatus) {
        mJobSet.add(jobStatus);
    }

    boolean containsJob(JobStatus jobStatus) {
        return mJobSet.contains(jobStatus);
    }
@@ -272,6 +280,14 @@ public final class JobStore {
        maybeWriteStatusToDiskAsync();
    }

    /**
     * The same as above but does not schedule writing. This makes perf benchmarks more stable.
     */
    @VisibleForTesting
    public void clearForTesting() {
        mJobSet.clear();
    }

    /**
     * @param userHandle User for whom we are querying the list of jobs.
     * @return A list of all the jobs scheduled for the provided user. Never null.
+5 −6
Original line number Diff line number Diff line
@@ -82,11 +82,10 @@ public class JobStorePerfTests {

        long elapsedTimeNs = 0;
        while (benchmarkState.keepRunning(elapsedTimeNs)) {
            sJobStore.clear();
            sJobStore.clearForTesting();
            for (JobStatus job : jobList) {
                sJobStore.add(job);
                sJobStore.addForTesting(job);
            }
            sJobStore.waitForWriteToCompleteForTesting(10_000);

            final long startTime = SystemClock.elapsedRealtimeNanos();
            sJobStore.writeStatusToDiskForTesting();
@@ -110,11 +109,11 @@ public class JobStorePerfTests {

        long elapsedTimeNs = 0;
        while (benchmarkState.keepRunning(elapsedTimeNs)) {
            sJobStore.clear();
            sJobStore.clearForTesting();
            for (JobStatus job : jobList) {
                sJobStore.add(job);
                sJobStore.addForTesting(job);
            }
            sJobStore.waitForWriteToCompleteForTesting(10_000);
            sJobStore.writeStatusToDiskForTesting();

            JobSet jobSet = new JobSet();