Merge "Change perf tests to have less deviation."
This commit is contained in:
committed by
Android (Google) Code Review
commit
156315ce50
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user