Skip to content

Commit 08aa98c

Browse files
Update couchbase perf test.
1 parent ae1591a commit 08aa98c

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

Couchbase/src/androidTest/java/de/greenrobot/performance/couchbase/PerfTestCouchbase.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Map;
2222

2323
/**
24-
* http://developer.couchbase.com/documentation/mobile/1.1.0/develop/training/build-first-android-app/index.html
24+
* http://developer.couchbase.com/documentation/mobile/1.2/develop/training/build-first-android-app/index.html
2525
* https://github.com/couchbaselabs/ToDoLite-Android
2626
*/
2727
public class PerfTestCouchbase extends BasePerfTestCase {
@@ -76,22 +76,17 @@ private void indexedStringEntityQueriesRun(View indexedStringView, int count)
7676
throws CouchbaseLiteException {
7777
// create entities
7878
String[] fixedRandomStrings = StringGenerator.createFixedRandomStrings(count);
79-
database.beginTransaction();
8079
for (int i = 0; i < count; i++) {
8180
Document entity = database.getDocument(String.valueOf(i));
8281
Map<String, Object> properties = new HashMap<>();
8382
properties.put("indexedString", fixedRandomStrings[i]);
8483
entity.putProperties(properties);
8584
}
86-
database.endTransaction(true);
8785
log("Built and inserted entities.");
8886

8987
// query for entities by indexed string at random
9088
int[] randomIndices = StringGenerator.getFixedRandomIndices(getQueryCount(), count - 1);
9189

92-
// clear the document cache to force loading properties from the database
93-
database.clearDocumentCache();
94-
9590
startClock();
9691
for (int i = 0; i < getQueryCount(); i++) {
9792
int nextIndex = randomIndices[i];
@@ -119,7 +114,9 @@ protected void doOneByOneAndBatchCrud() throws Exception {
119114
for (int i = 0; i < RUNS; i++) {
120115
log("----Run " + (i + 1) + " of " + RUNS);
121116
oneByOneCrudRun(getOneByOneCount());
122-
batchCrudRun(getBatchSize());
117+
// couchbase 1.2 has removed transaction support, do not run batch test
118+
// (only available for conflict resolution now)
119+
// batchCrudRun(getBatchSize());
123120
}
124121
}
125122

@@ -163,18 +160,15 @@ private void batchCrudRun(int count) throws Exception {
163160

164161
startClock();
165162
List<Document> documents = new ArrayList<>(count);
166-
database.beginTransaction();
167163
for (int i = 0; i < count; i++) {
168164
// use our own ids (use .createDocument() for random UUIDs)
169165
Document document = database.getDocument(String.valueOf(i));
170166
document.putProperties(maps.get(i));
171167
documents.add(document);
172168
}
173-
database.endTransaction(true);
174169
stopClock(LogMessage.BATCH_CREATE);
175170

176171
startClock();
177-
database.beginTransaction();
178172
for (int i = 0; i < count; i++) {
179173
Document document = documents.get(i);
180174
Map<String, Object> updatedProperties = new HashMap<>();
@@ -183,12 +177,8 @@ private void batchCrudRun(int count) throws Exception {
183177
updatedProperties.putAll(maps.get(i));
184178
document.putProperties(updatedProperties);
185179
}
186-
database.endTransaction(true);
187180
stopClock(LogMessage.BATCH_UPDATE);
188181

189-
// clear the document cache to force loading properties from the database
190-
database.clearDocumentCache();
191-
192182
startClock();
193183
List<Document> reloaded = new ArrayList<>();
194184
for (int i = 0; i < count; i++) {
@@ -223,12 +213,10 @@ private void deleteAll() throws CouchbaseLiteException {
223213
// query all documents, mark them as deleted
224214
Query query = database.createAllDocumentsQuery();
225215
QueryEnumerator result = query.run();
226-
database.beginTransaction();
227216
while (result.hasNext()) {
228217
QueryRow row = result.next();
229218
row.getDocument().purge();
230219
}
231-
database.endTransaction(true);
232220
}
233221

234222
private Map<String, Object> createDocumentMap(int seed) throws CouchbaseLiteException {

0 commit comments

Comments
 (0)