TIF: added query test cases in TvProviderPerfTest.
Test results on fugu:
Average elapsed time for (insert, update, query, delete):
> |lower_better|ms|918.81 1303.38 1776.51 2309.0
Average elapsed time for (insert, update, query, query partial programs, delete channels, delete programs):
> |lower_better|ms|889.17 1334.7 1901.3 13.24 183.31 169.56
Bug: 19653504
Change-Id: Ie257026d13ca3d9029a77d0354c1a4d2143841fd
diff --git a/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java b/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
index f43beb5..df89cae 100644
--- a/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
+++ b/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
@@ -49,6 +49,8 @@
* bar.
*/
public class TvProviderPerfTest extends CtsAndroidTestCase {
+ private static final int TRANSACTION_RUNS = 100;
+
private ContentResolver mContentResolver;
private String mInputId;
private boolean mHasTvInputFramework;
@@ -77,12 +79,11 @@
@TimeoutReq(minutes = 10)
public void testChannels() throws Exception {
if (!mHasTvInputFramework) return;
- double[] averages = new double[3];
+ double[] averages = new double[4];
// Insert
final ArrayList<ContentProviderOperation> operations = new ArrayList<>();
final int TRANSACTION_SIZE = 1000;
- final int TRANSACTION_RUNS = 100;
double[] applyBatchTimes = MeasureTime.measure(TRANSACTION_RUNS, new MeasureRun() {
@Override
public void run(int i) {
@@ -136,6 +137,23 @@
applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
averages[1] = Stat.getAverage(applyBatchTimes);
+ // Query
+ applyBatchTimes = MeasureTime.measure(TRANSACTION_RUNS, new MeasureRun() {
+ @Override
+ public void run(int i) {
+ int j = 0;
+ try (final Cursor cursor = mContentResolver.query(Channels.CONTENT_URI, null, null,
+ null, null)) {
+ while (cursor.moveToNext()) {
+ ++j;
+ }
+ }
+ }
+ });
+ getReportLog().printArray("Elapsed time for query: ",
+ applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
+ averages[2] = Stat.getAverage(applyBatchTimes);
+
// Delete
applyBatchTimes = MeasureTime.measure(1, new MeasureRun() {
@Override
@@ -145,17 +163,16 @@
});
getReportLog().printArray("Elapsed time for delete: ",
applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
- averages[2] = Stat.getAverage(applyBatchTimes);
+ averages[3] = Stat.getAverage(applyBatchTimes);
- // Query is not interesting for channels.
- getReportLog().printArray("Average elapsed time for (insert, update, delete): ",
+ getReportLog().printArray("Average elapsed time for (insert, update, query, delete): ",
averages, ResultType.LOWER_BETTER, ResultUnit.MS);
}
@TimeoutReq(minutes = 15)
public void testPrograms() throws Exception {
if (!mHasTvInputFramework) return;
- double[] averages = new double[5];
+ double[] averages = new double[6];
// Prepare (insert channels)
final ArrayList<ContentProviderOperation> operations = new ArrayList<>();
@@ -245,16 +262,12 @@
averages[1] = Stat.getAverage(applyBatchTimes);
// Query
- applyBatchTimes = MeasureTime.measure(NUM_CHANNELS, new MeasureRun() {
+ applyBatchTimes = MeasureTime.measure(TRANSACTION_RUNS, new MeasureRun() {
@Override
public void run(int i) {
- Uri channelUri = channelUris.get(i);
int j = 0;
- try (final Cursor cursor = mContentResolver.query(
- TvContract.buildProgramsUriForChannel(
- channelUri, 0,
- PROGRAM_DURATION_MS * TRANSACTION_SIZE / 2),
- projection, null, null, null)) {
+ try (final Cursor cursor = mContentResolver.query(Programs.CONTENT_URI, null, null,
+ null, null)) {
while (cursor.moveToNext()) {
++j;
}
@@ -265,6 +278,27 @@
applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
averages[2] = Stat.getAverage(applyBatchTimes);
+ // Query programs with selection
+ applyBatchTimes = MeasureTime.measure(NUM_CHANNELS, new MeasureRun() {
+ @Override
+ public void run(int i) {
+ Uri channelUri = channelUris.get(i);
+ int j = 0;
+ try (final Cursor cursor = mContentResolver.query(
+ TvContract.buildProgramsUriForChannel(
+ channelUri, 0,
+ PROGRAM_DURATION_MS * TRANSACTION_SIZE / 2),
+ null, null, null, null)) {
+ while (cursor.moveToNext()) {
+ ++j;
+ }
+ }
+ }
+ });
+ getReportLog().printArray("Elapsed time for query with selection: ",
+ applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
+ averages[3] = Stat.getAverage(applyBatchTimes);
+
// Delete programs
applyBatchTimes = MeasureTime.measure(NUM_CHANNELS, new MeasureRun() {
@Override
@@ -280,7 +314,7 @@
});
getReportLog().printArray("Elapsed time for delete programs: ",
applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
- averages[3] = Stat.getAverage(applyBatchTimes);
+ averages[4] = Stat.getAverage(applyBatchTimes);
// Delete channels
applyBatchTimes = MeasureTime.measure(NUM_CHANNELS, new MeasureRun() {
@@ -292,10 +326,10 @@
});
getReportLog().printArray("Elapsed time for delete channels: ",
applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
- averages[4] = Stat.getAverage(applyBatchTimes);
+ averages[5] = Stat.getAverage(applyBatchTimes);
getReportLog().printArray("Average elapsed time for (insert, update, query, "
- + "delete channels, delete programs): ",
+ + "query with selection, delete channels, delete programs): ",
averages, ResultType.LOWER_BETTER, ResultUnit.MS);
}
}