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

Side by Side Diff: chrome/test/data/indexeddb/perf_test.js

Issue 10856002: Make tests work in Firefox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fixes 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/indexeddb/perf_test.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var overallTestStartTime = Date.now(); 5 var overallTestStartTime = Date.now();
6 var kUseIndex = true; 6 var kUseIndex = true;
7 var kDontUseIndex = false; 7 var kDontUseIndex = false;
8 var kReadKeysOnly = true; 8 var kReadKeysOnly = true;
9 var kReadDataToo = false; 9 var kReadDataToo = false;
10 var kWriteToo = true; 10 var kWriteToo = true;
11 var kDontWrite = false; 11 var kDontWrite = false;
12 var kWriteSameStore = true; 12 var kWriteSameStore = true;
13 var kWriteDifferentStore = false; 13 var kWriteDifferentStore = false;
14 var kPlaceholderArg = false; 14 var kPlaceholderArg = false;
15 15
16 var tests = [ 16 var tests = [
17 // Create a single small item in a single object store, then delete everything. 17 // Create a single small item in a single object store, then delete everything.
18 [testCreateAndDeleteDatabase, 1, 1, 1], 18 [testCreateAndDeleteDatabase, 1, 1, 1],
19 // Create a single small item in a single object store, then delete everything. 19 // Create many small items in a single object store, then delete everything.
20 [testCreateAndDeleteDatabase, 100, 1, 1], 20 [testCreateAndDeleteDatabase, 1000, 1, 1],
21 // Create a single small item in a single object store, then delete everything. 21 // Create a single small item in many object stores, then delete everything.
22 [testCreateAndDeleteDatabase, 1, 100, 1], 22 [testCreateAndDeleteDatabase, 1, 1000, 1],
23 // Create a single small item in a single object store, then delete everything. 23 // Create many large items in a single object store, then delete everything.
24 [testCreateAndDeleteDatabase, 100, 1, 10000], 24 [testCreateAndDeleteDatabase, 1000, 1, 10000],
25 // Create a single small item in a single object store. 25 // Create a single small item in a single object store.
26 [testCreateKeysInStores, 1, 1, 1], 26 [testCreateKeysInStores, 1, 1, 1],
27 // Create many small items in a single object store. 27 // Create many small items in a single object store.
28 [testCreateKeysInStores, 100, 1, 1], 28 [testCreateKeysInStores, 1000, 1, 1],
29 // Create a single small item in many object stores. 29 // Create a single small item in many object stores.
30 [testCreateKeysInStores, 1, 100, 1], 30 [testCreateKeysInStores, 1, 1000, 1],
31 // Create many large items in a single object store. 31 // Create many large items in a single object store.
32 [testCreateKeysInStores, 100, 1, 10000], 32 [testCreateKeysInStores, 1000, 1, 10000],
33 // Read a few random items in each of many transactions. 33 // Read a few random items in each of many transactions.
34 [testRandomReadsAndWrites, 1000, 5, 0, 50, kDontUseIndex], 34 [testRandomReadsAndWrites, 1000, 5, 0, 100, kDontUseIndex],
35 // Read many random items in each of a few transactions. 35 // Read many random items in each of a few transactions.
36 [testRandomReadsAndWrites, 1000, 50, 0, 5, kDontUseIndex], 36 [testRandomReadsAndWrites, 1000, 500, 0, 5, kDontUseIndex],
37 // Read many random items in each of a few transactions, in a large store. 37 // Read many random items in each of a few transactions, in a large store.
38 [testRandomReadsAndWrites, 5000, 50, 0, 5, kDontUseIndex], 38 [testRandomReadsAndWrites, 10000, 500, 0, 5, kDontUseIndex],
39 // Read a few random items from an index, in each of many transactions. 39 // Read a few random items from an index, in each of many transactions.
40 [testRandomReadsAndWrites, 1000, 5, 0, 50, kUseIndex], 40 [testRandomReadsAndWrites, 1000, 5, 0, 100, kUseIndex],
41 // Read many random items from an index, in each of a few transactions. 41 // Read many random items from an index, in each of a few transactions.
42 [testRandomReadsAndWrites, 1000, 50, 0, 5, kUseIndex], 42 [testRandomReadsAndWrites, 1000, 500, 0, 5, kUseIndex],
43 // Read many random items from an index, in each of a few transactions, in a 43 // Read many random items from an index, in each of a few transactions, in a
44 // large store. 44 // large store.
45 [testRandomReadsAndWrites, 5000, 50, 0, 5, kUseIndex], 45 [testRandomReadsAndWrites, 10000, 500, 0, 5, kUseIndex],
46 // Read and write a few random items in each of many transactions. 46 // Read and write a few random items in each of many transactions.
47 [testRandomReadsAndWrites, 1000, 5, 5, 50, kDontUseIndex], 47 [testRandomReadsAndWrites, 1000, 5, 5, 50, kDontUseIndex],
48 // Read and write a few random items, reading from an index, in each of many 48 // Read and write a few random items, reading from an index, in each of many
49 // transactions. 49 // transactions.
50 [testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex], 50 [testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex],
51 // Read a long, contiguous sequence of an object store via a cursor. 51 // Read a long, contiguous sequence of an object store via a cursor.
52 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite, 52 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite,
53 kPlaceholderArg], 53 kPlaceholderArg],
54 // Read a sequence of an object store via a cursor, writing 54 // Read a sequence of an object store via a cursor, writing
55 // transformed values into another. 55 // transformed values into another.
56 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo, 56 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
57 kWriteDifferentStore], 57 kWriteDifferentStore],
58 // Read a sequence of an object store via a cursor, writing 58 // Read a sequence of an object store via a cursor, writing
59 // transformed values into another. 59 // transformed values into another.
60 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo, 60 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
61 kWriteSameStore], 61 kWriteSameStore],
62 // Read a sequence of an index into an object store via a cursor. 62 // Read a sequence of an index into an object store via a cursor.
63 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite, 63 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite,
64 kPlaceholderArg], 64 kPlaceholderArg],
65 // Read a sequence of an index into an object store via a key cursor. 65 // Read a sequence of an index into an object store via a key cursor.
66 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite, 66 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite,
67 kPlaceholderArg], 67 kPlaceholderArg],
68 // Make batches of random writes into a store, triggered by periodic setTimeout 68 // Make batches of random writes into a store, triggered by periodic setTimeout
69 // calls. 69 // calls.
70 [testSporadicWrites, 5, 0], 70 [testSporadicWrites, 5, 0],
71 // Make large batches of random writes into a store, triggered by periodic 71 // Make large batches of random writes into a store, triggered by periodic
72 // setTimeout calls. 72 // setTimeout calls.
73 [testSporadicWrites, 50, 0], 73 [testSporadicWrites, 500, 0],
74 // Make batches of random writes into a store with many indices, triggered by 74 // Make batches of random writes into a store with many indices, triggered by
75 // periodic setTimeout calls. 75 // periodic setTimeout calls.
76 [testSporadicWrites, 5, 10], 76 [testSporadicWrites, 5, 10],
77 // Make large batches of random writes into a store with many indices, triggered 77 // Make large batches of random writes into a store with many indices, triggered
78 // by periodic setTimeout calls. 78 // by periodic setTimeout calls.
79 [testSporadicWrites, 50, 10], 79 [testSporadicWrites, 500, 10],
80 // Create and delete an index on a store that already contains data [produces 80 // Create and delete an index on a store that already contains data [produces
81 // a timing result for each of creation and deletion]. 81 // a timing result for each of creation and deletion].
82 [testCreateAndDeleteIndex, 1000] 82 [testCreateAndDeleteIndex, 5000]
83 ]; 83 ];
84 84
85 var currentTest = 0; 85 var currentTest = 0;
86 86
87 function test() { 87 function test() {
88 runNextTest(); 88 runNextTest();
89 } 89 }
90 90
91 function runNextTest() { 91 function runNextTest() {
92 if (currentTest < tests.length) { 92 if (currentTest < tests.length) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 function onPopulated(db) { 265 function onPopulated(db) {
266 db.close(); 266 db.close();
267 automation.setStatus("Building index."); 267 automation.setStatus("Building index.");
268 startTime = Date.now(); 268 startTime = Date.now();
269 var f = function(objectStore) { 269 var f = function(objectStore) {
270 objectStore.createIndex("index", "firstName", {unique: true}); 270 objectStore.createIndex("index", "firstName", {unique: true});
271 }; 271 };
272 alterObjectStores(testName, objectStoreNames, f, onIndexCreated, onError); 272 alterObjectStores(testName, objectStoreNames, f, onIndexCreated, onError);
273 } 273 }
274 274
275 var completionFunc; 275 var indexCreationCompleteTime;
276 function onIndexCreated(db) { 276 function onIndexCreated(db) {
277 db.close(); 277 db.close();
278 var indexCreationCompleteTime = Date.now(); 278 indexCreationCompleteTime = Date.now();
279 automation.addResult("testCreateIndex", 279 automation.addResult("testCreateIndex",
280 indexCreationCompleteTime - startTime); 280 indexCreationCompleteTime - startTime);
281 completionFunc = getCompletionFunc(db, "testDeleteIndex",
282 indexCreationCompleteTime, onTestComplete);
283 var f = function(objectStore) { 281 var f = function(objectStore) {
284 objectStore.deleteIndex("index"); 282 objectStore.deleteIndex("index");
285 }; 283 };
286 automation.setStatus("Deleting index."); 284 automation.setStatus("Deleting index.");
287 alterObjectStores(testName, objectStoreNames, f, completionFunc, onError); 285 alterObjectStores(testName, objectStoreNames, f, onIndexDeleted, onError);
286 }
287
288 function onIndexDeleted(db) {
289 var duration = Date.now() - indexCreationCompleteTime;
290 // Ignore the cleanup time for this test.
291 automation.addResult("testDeleteIndex", duration);
292 automation.setStatus("Deleting database.");
293 db.close();
294 deleteDatabase(testName, onDeleted);
295 }
296
297 function onDeleted() {
298 automation.setStatus("Deleted database.");
299 onTestComplete();
288 } 300 }
289 } 301 }
290 302
291 function testCursorReadsAndRandomWrites( 303 function testCursorReadsAndRandomWrites(
292 readKeysOnly, useIndexForReads, writeAlso, sameStoreForWrites, 304 readKeysOnly, useIndexForReads, writeAlso, sameStoreForWrites,
293 onTestComplete) { 305 onTestComplete) {
294 // There's no key cursor unless you're reading from an index. 306 // There's no key cursor unless you're reading from an index.
295 assert(useIndexForReads || !readKeysOnly); 307 assert(useIndexForReads || !readKeysOnly);
296 // If we're writing to another store, having an index would constrain our 308 // If we're writing to another store, having an index would constrain our
297 // writes, as we create both object stores with the same configurations. 309 // writes, as we create both object stores with the same configurations.
298 // We could do that if needed, but it's simpler not to. 310 // We could do that if needed, but it's simpler not to.
299 assert(!useIndexForReads || !writeAlso); 311 assert(!useIndexForReads || !writeAlso);
300 var numKeys = 1000; 312 var numKeys = 10000;
301 var numReadsPerTransaction = 100; 313 var numReadsPerTransaction = 1000;
302 var testName = getDisplayName(arguments); 314 var testName = getDisplayName(arguments);
303 var objectStoreNames = ["input store"]; 315 var objectStoreNames = ["input store"];
304 var outputStoreName; 316 var outputStoreName;
305 if (writeAlso) { 317 if (writeAlso) {
306 if (sameStoreForWrites) { 318 if (sameStoreForWrites) {
307 outputStoreName = objectStoreNames[0]; 319 outputStoreName = objectStoreNames[0];
308 } else { 320 } else {
309 outputStoreName = "output store"; 321 outputStoreName = "output store";
310 objectStoreNames.push(outputStoreName); 322 objectStoreNames.push(outputStoreName);
311 } 323 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 428
417 var mode = "readonly"; 429 var mode = "readonly";
418 if (numWritesPerTransaction) 430 if (numWritesPerTransaction)
419 mode = "readwrite"; 431 mode = "readwrite";
420 432
421 var transaction = getTransaction(db, objectStoreNames, mode, batchComplete); 433 var transaction = getTransaction(db, objectStoreNames, mode, batchComplete);
422 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction, 434 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction,
423 numKeys); 435 numKeys);
424 } 436 }
425 } 437 }
OLDNEW
« no previous file with comments | « chrome/test/data/indexeddb/perf_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698