diff options
author | Tapani Mikola <tapani.mikola@nokia.com> | 2012-06-07 09:32:53 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-07 16:42:58 +0200 |
commit | 7dc8267d3e21d4489deb2fe2006ddaa691f1d753 (patch) | |
tree | 0935a3243bc05a8ff432eb843c725784e2d44b19 /tests | |
parent | ee2d4f3376f9e71904fea7ad3481b6103ff52f3e (diff) |
Add a benchmark that mimics the way how list model uses jsondb
Change-Id: Ia5895aa11728a2c4e2f6478bc39540dfc393dff3
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/partition/bench_partition.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/benchmarks/partition/bench_partition.cpp b/tests/benchmarks/partition/bench_partition.cpp index c611e389..c52280a8 100644 --- a/tests/benchmarks/partition/bench_partition.cpp +++ b/tests/benchmarks/partition/bench_partition.cpp @@ -114,6 +114,7 @@ private slots: void benchmarkFirst10(); void benchmarkFind10(); void benchmarkFind20(); + void benchmarkIteratePageByPage(); void benchmarkFirstByUuid(); void benchmarkLastByUuid(); void benchmarkFirst10ByUuid(); @@ -849,6 +850,38 @@ void TestPartition::benchmarkFind20() } } +void TestPartition::benchmarkIteratePageByPage() +{ + // Simulate JsonDbListModel hammering the database + // Scroll bottom up and then down and up + int count = mContactList.size(); + if (!count) + return; + + QBENCHMARK { + QString query = QString("[?%1=\"%2\"][?name.last exists][/name.first]") + .arg(JsonDbString::kTypeStr) + .arg("contact"); + JsonDbQueryParser parser; + parser.setQuery(query); + QVERIFY(parser.parse()); + JsonDbQuery parsedQuery = parser.result(); + int pageSize = 10; + for (int offset = count-pageSize; offset >= 0; offset -= pageSize) { + JsonDbQueryResult queryResult = mJsonDbPartition->queryObjects(mOwner, parsedQuery, pageSize, offset < 0 ? 0 : offset); + verifyGoodQueryResult(queryResult); + } + for (int offset = 0; offset < count; offset += pageSize) { + JsonDbQueryResult queryResult = mJsonDbPartition->queryObjects(mOwner, parsedQuery, pageSize, offset); + verifyGoodQueryResult(queryResult); + } + for (int offset = count-pageSize; offset >= 0; offset -= pageSize) { + JsonDbQueryResult queryResult = mJsonDbPartition->queryObjects(mOwner, parsedQuery, pageSize, offset < 0 ? 0 : offset); + verifyGoodQueryResult(queryResult); + } + } +} + void TestPartition::benchmarkFirstByUuid() { int count = mContactList.size(); |