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

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: Rolled in code review feedback. 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
« 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 708fc3f625b1286f9defbc7c16abc227357b5c3a..d4408c29ed7204d33cdc77d12d37699028d9d064 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]
@@ -185,9 +193,7 @@ function testRandomReadsAndWrites(
if (useIndexForReads)
indexName = "index";
var testName = getDisplayName(arguments);
- var numTransactionsLeft = numTransactions;
var objectStoreNames = ["store"];
- var numTransactionsRunning;
automation.setStatus("Creating database.");
var options;
@@ -206,36 +212,21 @@ function testRandomReadsAndWrites(
var transaction = getTransaction(db, objectStoreNames, "readwrite",
function() { onSetupComplete(db); });
putLinearValues(transaction, objectStoreNames, numKeys, null,
- function () { return "test value"; });
+ function() { return "test value"; });
}
- var completionFunc;
function onSetupComplete(db) {
automation.setStatus("Setup complete.");
- completionFunc =
+ var completionFunc =
getCompletionFunc(db, testName, Date.now(), onTestComplete);
- runOneBatch(db);
- }
-
- function runOneBatch(db) {
- if (numTransactionsLeft <= 0) {
- return;
- }
- --numTransactionsLeft;
- ++numTransactionsRunning;
var mode = "readonly";
if (numWritesPerTransaction)
mode = "readwrite";
- var transaction = getTransaction(db, objectStoreNames, mode,
- function() {
- assert(!--numTransactionsRunning);
- if (numTransactionsLeft <= 0) {
- completionFunc();
- } else {
- runOneBatch(db);
- }
- });
+ runTransactionBatch(db, numTransactions, batchFunc, objectStoreNames, mode,
+ completionFunc);
+ }
+ function batchFunc(transaction) {
getRandomValues(transaction, objectStoreNames, numReadsPerTransaction,
numKeys, indexName);
putRandomValues(transaction, objectStoreNames, numWritesPerTransaction,
@@ -243,6 +234,55 @@ 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 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"; });
+ }
+
+ var completionFunc;
+ function onSetupComplete(db) {
+ automation.setStatus("Setup complete.");
+ completionFunc =
+ getCompletionFunc(db, testName, Date.now(), onTestComplete);
+ runTransactionBatch(db, numTransactions, batchFunc, objectStoreNames,
+ "readonly", completionFunc);
+ }
+
+ function batchFunc(transaction) {
+ getSpecificValues(transaction, objectStoreNames, indexName, keys);
+ }
+}
+
function testCreateAndDeleteIndex(numKeys, onTestComplete) {
var testName = getDisplayName(arguments);
var objectStoreNames = ["store"];
« 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