Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5549)

Unified Diff: chrome/test/data/indexeddb/perf_test.js

Issue 12780007: IndexedDB: Add performance test calling continue(key) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/indexeddb/perf_test.js
diff --git a/chrome/test/data/indexeddb/perf_test.js b/chrome/test/data/indexeddb/perf_test.js
index a90b69999f43dfffc9dc3f1dbe9c6cea40b5f8f7..8b2adea40359f70f7585c9b447a58277b8423f5b 100644
--- a/chrome/test/data/indexeddb/perf_test.js
+++ b/chrome/test/data/indexeddb/perf_test.js
@@ -105,6 +105,10 @@ var tests = [
// Walk through many cursors into the same object store, round-robin, until
// you've reached the end of each of them.
[testWalkingMultipleCursors, 50],
+// Open an object store cursor, then continue(key) to the last value.
+ [testCursorSeeks, 2000, 10, 4, kDontUseIndex],
+// Open an index key cursor, then continue(key) to the last value.
+ [testCursorSeeks, 2000, 10, 4, kUseIndex],
];
var currentTest = 0;
@@ -604,3 +608,68 @@ function testWalkingMultipleCursors(numCursors, onTestComplete) {
}
}
+function testCursorSeeks(
+ numKeys, numSeeksPerTransaction, numTransactions, useIndexForReads,
+ onTestComplete) {
+ var testName = getDisplayName(arguments);
+ var objectStoreNames = ["store"];
+ var getKey = useIndexForReads ? getForwardIndexKey : getSimpleKey;
+ var indexName;
+ if (useIndexForReads) {
+ indexName = "index";
+ }
+
+ automation.setStatus("Creating database.");
+ var options;
+ if (useIndexForReads) {
+ options = [{
+ indexName: indexName,
+ indexKeyPath: "firstName",
+ indexIsUnique: true,
+ indexIsMultiEntry: false,
+ }];
+ }
+ createDatabase(testName, objectStoreNames, onCreated, onError, options);
+
+ function onCreated(db) {
+ automation.setStatus("Setting up test database.");
+ var transaction = getTransaction(db, objectStoreNames, "readwrite",
+ function() { onSetupComplete(db); });
+ putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey,
+ getObjectValue);
+ }
+
+ function onSetupComplete(db) {
+ automation.setStatus("Setup complete.");
+ var completionFunc =
+ getCompletionFunc(db, testName, Date.now(), onTestComplete);
+ var mode = "readonly";
+ runTransactionBatch(db, numTransactions, batchFunc, objectStoreNames, mode,
+ completionFunc);
+ }
+
+ function batchFunc(transaction) {
+ for (var i in objectStoreNames) {
+ var source = transaction.objectStore(objectStoreNames[i]);
+ if (useIndexForReads)
+ source = source.index(indexName);
+ for (var j = 0; j < numSeeksPerTransaction; ++j) {
+ randomSeek(source);
+ }
+ }
+ }
+
+ function randomSeek(source) {
+ var request = useIndexForReads ? source.openKeyCursor()
+ : source.openCursor();
+ var first = true;
+ request.onerror = onError;
+ request.onsuccess = function() {
+ var cursor = request.result;
+ if (cursor && first) {
+ first = false;
+ cursor.continue(getKey(numKeys - 1));
+ }
+ };
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698