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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 [testReadCache, 50, kUseIndex], 98 [testReadCache, 50, kUseIndex],
99 // Create and delete an index on a store that already contains data [produces 99 // Create and delete an index on a store that already contains data [produces
100 // a timing result for each of creation and deletion]. 100 // a timing result for each of creation and deletion].
101 [testCreateAndDeleteIndex, 5000], 101 [testCreateAndDeleteIndex, 5000],
102 // Walk through multiple cursors into the same object store, round-robin, until 102 // Walk through multiple cursors into the same object store, round-robin, until
103 // you've reached the end of each of them. 103 // you've reached the end of each of them.
104 [testWalkingMultipleCursors, 5], 104 [testWalkingMultipleCursors, 5],
105 // Walk through many cursors into the same object store, round-robin, until 105 // Walk through many cursors into the same object store, round-robin, until
106 // you've reached the end of each of them. 106 // you've reached the end of each of them.
107 [testWalkingMultipleCursors, 50], 107 [testWalkingMultipleCursors, 50],
108 // Open an object store cursor, then continue(key) to the last value.
109 [testCursorSeeks, 2000, 10, 4, kDontUseIndex],
110 // Open an index key cursor, then continue(key) to the last value.
111 [testCursorSeeks, 2000, 10, 4, kUseIndex],
108 ]; 112 ];
109 113
110 var currentTest = 0; 114 var currentTest = 0;
111 115
112 function test() { 116 function test() {
113 runNextTest(); 117 runNextTest();
114 } 118 }
115 119
116 function runNextTest() { 120 function runNextTest() {
117 var filter = window.location.hash.slice(1); 121 var filter = window.location.hash.slice(1);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 601 }
598 }; 602 };
599 } 603 }
600 } 604 }
601 function verifyComplete() { 605 function verifyComplete() {
602 assert(!cursorsRunning); 606 assert(!cursorsRunning);
603 completionFunc(); 607 completionFunc();
604 } 608 }
605 } 609 }
606 610
611 function testCursorSeeks(
612 numKeys, numSeeksPerTransaction, numTransactions, useIndexForReads,
613 onTestComplete) {
614 var testName = getDisplayName(arguments);
615 var objectStoreNames = ["store"];
616 var getKey = useIndexForReads ? getForwardIndexKey : getSimpleKey;
617 var indexName;
618 if (useIndexForReads) {
619 indexName = "index";
620 }
621
622 automation.setStatus("Creating database.");
623 var options;
624 if (useIndexForReads) {
625 options = [{
626 indexName: indexName,
627 indexKeyPath: "firstName",
628 indexIsUnique: true,
629 indexIsMultiEntry: false,
630 }];
631 }
632 createDatabase(testName, objectStoreNames, onCreated, onError, options);
633
634 function onCreated(db) {
635 automation.setStatus("Setting up test database.");
636 var transaction = getTransaction(db, objectStoreNames, "readwrite",
637 function() { onSetupComplete(db); });
638 putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey,
639 getObjectValue);
640 }
641
642 function onSetupComplete(db) {
643 automation.setStatus("Setup complete.");
644 var completionFunc =
645 getCompletionFunc(db, testName, Date.now(), onTestComplete);
646 var mode = "readonly";
647 runTransactionBatch(db, numTransactions, batchFunc, objectStoreNames, mode,
648 completionFunc);
649 }
650
651 function batchFunc(transaction) {
652 for (var i in objectStoreNames) {
653 var source = transaction.objectStore(objectStoreNames[i]);
654 if (useIndexForReads)
655 source = source.index(indexName);
656 for (var j = 0; j < numSeeksPerTransaction; ++j) {
657 randomSeek(source);
658 }
659 }
660 }
661
662 function randomSeek(source) {
663 var request = useIndexForReads ? source.openKeyCursor()
664 : source.openCursor();
665 var first = true;
666 request.onerror = onError;
667 request.onsuccess = function() {
668 var cursor = request.result;
669 if (cursor && first) {
670 first = false;
671 cursor.continue(getKey(numKeys - 1));
672 }
673 };
674 }
675 }
OLDNEW
« 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