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

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

Issue 10836063: Add deletion test, cursor read with writeback to same store. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add bug number. Created 8 years, 5 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 | « chrome/test/data/indexeddb/perf_shared.js ('k') | 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 75b193c2421289c375e8cac81675e39f00bb3aee..106355fd994009c078806023f057e676ced64e30 100644
--- a/chrome/test/data/indexeddb/perf_test.js
+++ b/chrome/test/data/indexeddb/perf_test.js
@@ -9,8 +9,23 @@ var kReadKeysOnly = true;
var kReadDataToo = false;
var kWriteToo = true;
var kDontWrite = false;
+var kWriteSameStore = true;
+var kWriteDifferentStore = false;
+var kPlaceholderArg = false;
var tests = [
+ /* These tests give crazy results, and the fourth times out.
+ * See crbug.com/140123.
+
+// Create a few small items in a single object store, then delete everything.
+ [testCreateAndDeleteDatabase, 4, 1, 1],
+// Create a few small items in a single object store, then delete everything.
+ [testCreateAndDeleteDatabase, 3, 1, 1],
+// Create a couple small items in a single object store, then delete everything.
+ [testCreateAndDeleteDatabase, 2, 1, 1],
+// Create a single small items in a single object store, then delete everything.
+ [testCreateAndDeleteDatabase, 1, 1, 1],
+ */
// Create a single small item in a single object store.
[testCreateKeysInStores, 1, 1, 1],
// Create many small items in a single object store.
@@ -38,14 +53,22 @@ var tests = [
// transactions.
[testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex],
// Read a long, contiguous sequence of an object store via a cursor.
- [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite],
+ [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite,
+ kPlaceholderArg],
// Read a sequence of an object store via a cursor, writing
// transformed values into another.
- [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo],
+ [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
+ kWriteDifferentStore],
+// Read a sequence of an object store via a cursor, writing
+// transformed values into another.
+ [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
+ kWriteSameStore],
// Read a sequence of an index into an object store via a cursor.
- [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite],
+ [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite,
+ kPlaceholderArg],
// Read a sequence of an index into an object store via a key cursor.
- [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite],
+ [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite,
+ kPlaceholderArg],
// Make batches of random writes into a store, triggered by periodic setTimeout
// calls.
[testSporadicWrites, 5, 0],
@@ -86,6 +109,45 @@ function onAllTestsComplete() {
automation.setDone();
}
+function testCreateAndDeleteDatabase(
+ numKeys, numStores, payloadLength, onTestComplete) {
+ var testName = getDisplayName(arguments);
+ assert(numKeys >= 0);
+ assert(numStores >= 1);
+ var objectStoreNames = [];
+ for (var i=0; i < numStores; ++i) {
+ objectStoreNames.push("store " + i);
+ }
+ var value = stringOfLength(payloadLength);
+ function getValue() {
+ return value;
+ }
+
+ automation.setStatus("Creating database.");
+ var startTime = Date.now();
+
+ createDatabase(testName, objectStoreNames, onCreated, onError);
+
+ function onCreated(db) {
+ automation.setStatus("Constructing transaction.");
+ var transaction =
+ getTransaction(db, objectStoreNames, "readwrite", onValuesWritten);
+ putLinearValues(transaction, objectStoreNames, numKeys, null, getValue);
+ }
+
+ function onValuesWritten() {
+ automation.setStatus("Deleting database.");
+ deleteDatabase(testName, onDeleted);
jsbell 2012/08/01 23:05:26 Need to call db.close() before deleteDatabase() or
ericu 2012/08/01 23:39:43 Added onblocked.
+ }
+
+ function onDeleted() {
+ var duration = Date.now() - startTime;
+ automation.addResult(testName, duration);
+ automation.setStatus("Deleted database.");
+ onTestComplete();
+ }
+}
+
function testCreateKeysInStores(
numKeys, numStores, payloadLength, onTestComplete) {
var testName = getDisplayName(arguments);
@@ -222,22 +284,28 @@ function testCreateAndDeleteIndex(numKeys, onTestComplete) {
}
}
-// TODO: Add a version that writes back to the same store, to see how that
-// affects cursor speed w.r.t. invalidated caches.
function testCursorReadsAndRandomWrites(
- readKeysOnly, useIndexForReads, writeToAnotherStore, onTestComplete) {
+ readKeysOnly, useIndexForReads, writeAlso, sameStoreForWrites,
+ onTestComplete) {
// There's no key cursor unless you're reading from an index.
assert(useIndexForReads || !readKeysOnly);
// If we're writing to another store, having an index would constrain our
// writes, as we create both object stores with the same configurations.
// We could do that if needed, but it's simpler not to.
- assert(!useIndexForReads || !writeToAnotherStore);
+ assert(!useIndexForReads || !writeAlso);
var numKeys = 1000;
var numReadsPerTransaction = 100;
var testName = getDisplayName(arguments);
var objectStoreNames = ["input store"];
- if (writeToAnotherStore)
- objectStoreNames.push("output store");
+ var outputStoreName;
+ if (writeAlso) {
+ if (sameStoreForWrites) {
+ outputStoreName = objectStoreNames[0];
+ } else {
+ outputStoreName = "output store";
+ objectStoreNames.push(outputStoreName);
+ }
+ }
var getKeyForRead = getSimpleKey;
var indexName;
if (useIndexForReads) {
@@ -275,14 +343,14 @@ function testCursorReadsAndRandomWrites(
var completionFunc =
getCompletionFunc(testName, Date.now(), onTestComplete);
var mode = "readonly";
- if (writeToAnotherStore)
+ if (writeAlso)
mode = "readwrite";
var transaction =
getTransaction(db, objectStoreNames, mode, completionFunc);
getValuesFromCursor(
transaction, objectStoreNames[0], numReadsPerTransaction, numKeys,
- indexName, getKeyForRead, readKeysOnly, objectStoreNames[1]);
+ indexName, getKeyForRead, readKeysOnly, outputStoreName);
}
}
« no previous file with comments | « chrome/test/data/indexeddb/perf_shared.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698