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

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

Issue 10854046: Add cache test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add cache test length variants Created 8 years, 4 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
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 708fc3f625b1286f9defbc7c16abc227357b5c3a..244c3d7966e83cd2ef03c056ef9a550f9b2fd463 100644
--- a/chrome/test/data/indexeddb/perf_test.js
+++ b/chrome/test/data/indexeddb/perf_test.js
@@ -77,6 +77,14 @@ var tests = [
// Make large batches of random writes into a store with many indices, triggered
// by periodic setTimeout calls.
[testSporadicWrites, 500, 10],
+// Make a small bunch of batches of reads of the same keys from an object store.
+ [testReadCache, 10, kDontUseIndex],
+// Make a bunch of batches of reads of the same keys from an index.
+ [testReadCache, 50, kUseIndex],
+// Make a small bunch of batches of reads of the same keys from an object store.
+ [testReadCache, 10, kDontUseIndex],
+// Make a bunch of batches of reads of the same keys from an index.
+ [testReadCache, 50, kUseIndex],
// Create and delete an index on a store that already contains data [produces
// a timing result for each of creation and deletion].
[testCreateAndDeleteIndex, 5000]
@@ -243,6 +251,70 @@ function testRandomReadsAndWrites(
}
}
+function testReadCache(numTransactions, useIndexForReads, onTestComplete) {
+ var numKeys = 10000;
+ var numReadsPerTransaction = 50;
+ var numTransactionsLeft = numTransactions;
+ var indexName;
+ if (useIndexForReads)
+ indexName = "index";
+ var testName = getDisplayName(arguments);
+ var objectStoreNames = ["store"];
+ var numTransactionsRunning;
+ var keys = [];
+
+ for (var i=0; i < numReadsPerTransaction; ++i) {
+ keys.push(getSimpleKey(Math.floor(Math.random() * numKeys)));
+ }
+
+ automation.setStatus("Creating database.");
+ var options;
+ if (useIndexForReads) {
+ options = [{
+ indexName: indexName,
+ indexKeyPath: "",
+ indexIsUnique: false,
+ 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,
+ function () { return "test value"; });
jsbell 2012/08/09 17:58:18 Nit: space between function keyword and ()
ericu 2012/08/15 17:56:22 Done.
+ }
+
+ var completionFunc;
+ function onSetupComplete(db) {
+ automation.setStatus("Setup complete.");
+ completionFunc =
+ getCompletionFunc(db, testName, Date.now(), onTestComplete);
+ runOneBatch(db);
+ }
+
+ function runOneBatch(db) {
jsbell 2012/08/09 17:58:18 This runOneBatch() pattern seems to be re-used in
ericu 2012/08/15 17:56:22 It's used in 3 places, but one is actually differe
+ if (numTransactionsLeft <= 0) {
+ return;
+ }
+ --numTransactionsLeft;
+ ++numTransactionsRunning;
+ var transaction = getTransaction(db, objectStoreNames, "readonly",
+ function() {
+ assert(!--numTransactionsRunning);
+ if (numTransactionsLeft <= 0) {
+ completionFunc();
+ } else {
+ runOneBatch(db);
+ }
+ });
+
+ getSpecificValues(transaction, objectStoreNames, indexName, keys);
+ }
+}
+
function testCreateAndDeleteIndex(numKeys, onTestComplete) {
var testName = getDisplayName(arguments);
var objectStoreNames = ["store"];
« chrome/test/data/indexeddb/perf_shared.js ('K') | « 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