Skip to content

Instantly share code, notes, and snippets.

@kurorido
Last active August 29, 2015 14:03
Show Gist options
  • Save kurorido/36bec5a1b807e85ad040 to your computer and use it in GitHub Desktop.
Save kurorido/36bec5a1b807e85ad040 to your computer and use it in GitHub Desktop.
Update Couchbase Without View
void testUpdateCouchBaseWithoutView() {
print("Testing Update CouchBase without View...");
CouchClient _dbclient;
CouchClient.connect([Uri.parse("http://10.1.4.112:8091/pools")], "default", "").then((CouchClient c) {
_dbclient = c;
}).then((_) {
int startTime = new DateTime.now().millisecondsSinceEpoch;
List<Future> futures = new List();
// Modify i Value to test different range
for (var i = 5000; i < 15000; i++) {
futures.add(_dbclient.get(i.toString()).then((r) {
List old = JSON.decode(UTF8.decode(r.data));
old[1] = old[1] + "modified";
_dbclient.set(i.toString(), UTF8.encode(JSON.encode(old)));
}));
}
Future.wait(futures).then((_) {
int endTime = new DateTime.now().millisecondsSinceEpoch;
int timeCost = endTime - startTime;
print(timeCost.toString() + "ms");
// Couchbase server is on Remote VM
// Result for Range = 100 => 155ms
// Result for Range = 1000 => 602ms
// Result for Range = 10000 => 2453ms
}).whenComplete(() {
_dbclient.close();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment