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

Side by Side Diff: tools/perf/page_sets/indexeddb_perf/perf_test.js

Issue 1238393003: [IndexedDB] Adding traces, perf tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 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
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 = window.performance.now(); 5 var overallTestStartTime = window.performance.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 var kDontRead = false; 15 var kDontRead = false;
16 var kAlternateWithReads = true; 16 var kAlternateWithReads = true;
17 17
18 var tests = [ 18 var tests = [
19 // Create 30 databases, populate them with 10 object stores with 10 items
cmumford 2015/08/03 17:31:34 20 object stores right?
20 // each, and then open them 100 times.
21 [testCreateAndDeleteDatabases, 30, 60, 10, 20, 100],
19 // Create a single small item in a single object store, then delete everything. 22 // Create a single small item in a single object store, then delete everything.
20 [testCreateAndDeleteDatabase, 1, 1, 1], 23 [testCreateAndDeleteDatabase, 1, 1, 1],
21 // Create many small items in a single object store, then delete everything. 24 // Create many small items in a single object store, then delete everything.
22 [testCreateAndDeleteDatabase, 1000, 1, 1], 25 [testCreateAndDeleteDatabase, 1000, 1, 1],
23 // Create a single small item in many object stores, then delete everything. 26 // Create a single small item in many object stores, then delete everything.
24 [testCreateAndDeleteDatabase, 1, 1000, 1], 27 [testCreateAndDeleteDatabase, 1, 1000, 1],
25 // Create many large items in a single object store, then delete everything. 28 // Create many large items in a single object store, then delete everything.
26 [testCreateAndDeleteDatabase, 1000, 1, 10000], 29 [testCreateAndDeleteDatabase, 1000, 1, 10000],
27 // Create a single small item in a single object store. 30 // Create a single small item in a single object store.
28 [testCreateKeysInStores, 1, 1, 1], 31 [testCreateKeysInStores, 1, 1, 1],
29 // Create many small items in a single object store. 32 // Create many small items in a single object store.
30 [testCreateKeysInStores, 1000, 1, 1], 33 [testCreateKeysInStores, 1000, 1, 1],
31 // Create a single small item in many object stores. 34 // Create a single small item in many object stores.
32 [testCreateKeysInStores, 1, 1000, 1], 35 [testCreateKeysInStores, 1, 1000, 1],
33 // Create many large items in a single object store. 36 // Create many large items in a single object store.
34 [testCreateKeysInStores, 1000, 1, 10000], 37 [testCreateKeysInStores, 1000, 1, 10000],
38
35 // Read one item per transaction. 39 // Read one item per transaction.
36 [testRandomReadsAndWrites, 1000, 1, 0, 1000, kDontUseIndex], 40 [testRandomReadsAndWritesWithoutIndex, 1000, 1, 0, 1000],
37 // Read a few random items in each of many transactions. 41 // Read a few random items in each of many transactions.
38 [testRandomReadsAndWrites, 1000, 5, 0, 100, kDontUseIndex], 42 [testRandomReadsAndWritesWithoutIndex, 1000, 5, 0, 100],
39 // Read many random items in each of a few transactions. 43 // Read many random items in each of a few transactions.
40 [testRandomReadsAndWrites, 1000, 500, 0, 5, kDontUseIndex], 44 [testRandomReadsAndWritesWithoutIndex, 1000, 500, 0, 5],
41 // Read many random items in each of a few transactions, in a large store. 45 // Read many random items in each of a few transactions, in a large store.
42 [testRandomReadsAndWrites, 10000, 500, 0, 5, kDontUseIndex], 46 [testRandomReadsAndWritesWithoutIndex, 10000, 500, 0, 5],
47 // Read and write a few random items in each of many transactions.
48 [testRandomReadsAndWritesWithoutIndex, 1000, 5, 5, 50],
cmumford 2015/08/03 17:31:34 Will moving 1000, 5, 5, 50, w/o up here change the
dmurph 2015/08/05 15:30:33 Not sure. Hm..... you want to avoid differences fo
49
43 // Read a few random items from an index, in each of many transactions. 50 // Read a few random items from an index, in each of many transactions.
44 [testRandomReadsAndWrites, 1000, 5, 0, 100, kUseIndex], 51 [testRandomReadsAndWritesWithIndex, 1000, 5, 0, 100],
45 // Read many random items from an index, in each of a few transactions. 52 // Read many random items from an index, in each of a few transactions.
46 [testRandomReadsAndWrites, 1000, 500, 0, 5, kUseIndex], 53 [testRandomReadsAndWritesWithIndex, 1000, 500, 0, 5],
47 // Read many random items from an index, in each of a few transactions, in a 54 // Read many random items from an index, in each of a few transactions, in a
48 // large store. 55 // large store.
49 [testRandomReadsAndWrites, 10000, 500, 0, 5, kUseIndex], 56 [testRandomReadsAndWritesWithIndex, 10000, 500, 0, 5],
50 // Read and write a few random items in each of many transactions.
51 [testRandomReadsAndWrites, 1000, 5, 5, 50, kDontUseIndex],
52 // Read and write a few random items, reading from an index, in each of many 57 // Read and write a few random items, reading from an index, in each of many
53 // transactions. 58 // transactions.
54 [testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex], 59 [testRandomReadsAndWritesWithIndex, 1000, 5, 5, 50],
60
55 // Read a long, contiguous sequence of an object store via a cursor. 61 // Read a long, contiguous sequence of an object store via a cursor.
56 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite, 62 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite,
57 kPlaceholderArg], 63 kPlaceholderArg],
58 // Read a sequence of an object store via a cursor, writing 64 // Read a sequence of an object store via a cursor, writing
59 // transformed values into another. 65 // transformed values into another.
60 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo, 66 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
61 kWriteDifferentStore], 67 kWriteDifferentStore],
62 // Read a sequence of an object store via a cursor, writing 68 // Read a sequence of an object store via a cursor, writing
63 // transformed values into another. 69 // transformed values into another.
64 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo, 70 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo,
65 kWriteSameStore], 71 kWriteSameStore],
66 // Read a sequence of an index into an object store via a cursor. 72 // Read a sequence of an index into an object store via a cursor.
67 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite, 73 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite,
68 kPlaceholderArg], 74 kPlaceholderArg],
69 // Read a sequence of an index into an object store via a key cursor. 75 // Read a sequence of an index into an object store via a key cursor.
70 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite, 76 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite,
71 kPlaceholderArg], 77 kPlaceholderArg],
78
72 // Make a small bunch of batches of reads of the same keys from an object store. 79 // Make a small bunch of batches of reads of the same keys from an object store.
73 [testReadCache, 10, kDontUseIndex], 80 [testReadCacheWithoutIndex, 10],
81 // Make a bunch of batches of reads of the same keys from an object store.
82 [testReadCacheWithoutIndex, 50],
cmumford 2015/08/03 17:31:34 Previously 50 used the index, and 10 didn't. Was t
dmurph 2015/08/05 15:30:33 It was intentional here. Previously we just did t
83 // Make a small bunch of batches of reads of the same keys from an object store.
84 [testReadCacheWithIndex, 10],
74 // Make a bunch of batches of reads of the same keys from an index. 85 // Make a bunch of batches of reads of the same keys from an index.
75 [testReadCache, 50, kUseIndex], 86 [testReadCacheWithIndex, 50],
76 // Make a small bunch of batches of reads of the same keys from an object store. 87
77 [testReadCache, 10, kDontUseIndex],
78 // Make a bunch of batches of reads of the same keys from an index.
79 [testReadCache, 50, kUseIndex],
80 // Create and delete an index on a store that already contains data [produces 88 // Create and delete an index on a store that already contains data [produces
81 // a timing result for each of creation and deletion]. 89 // a timing result for each of creation and deletion].
82 [testCreateAndDeleteIndex, 5000], 90 [testCreateAndDeleteIndex, 5000],
83 // Walk through multiple cursors into the same object store, round-robin, until 91 // Walk through multiple cursors into the same object store, round-robin, until
84 // you've reached the end of each of them. 92 // you've reached the end of each of them.
85 [testWalkingMultipleCursors, 5], 93 [testWalkingMultipleCursors, 5],
86 // Walk through many cursors into the same object store, round-robin, until 94 // Walk through many cursors into the same object store, round-robin, until
87 // you've reached the end of each of them. 95 // you've reached the end of each of them.
88 [testWalkingMultipleCursors, 50], 96 [testWalkingMultipleCursors, 50],
89 // Open an object store cursor, then continue(key) to the last value. 97 // Open an object store cursor, then continue(key) to the last value.
90 [testCursorSeeks, 2000, 10, 4, kDontUseIndex], 98 [testCursorSeeksWithoutIndex, 2000, 10, 4],
91 // Open an index key cursor, then continue(key) to the last value. 99 // Open an index key cursor, then continue(key) to the last value.
92 [testCursorSeeks, 2000, 10, 4, kUseIndex], 100 [testCursorSeeksWithIndex, 2000, 10, 4],
93 ]; 101 ];
94 102
103
104 function testRandomReadsAndWritesWithIndex(
105 numKeys, numReadsPerTransaction, numWritesPerTransaction,
106 numTransactions, onTestComplete) {
107 testRandomReadsAndWrites(numKeys, numReadsPerTransaction,
108 numWritesPerTransaction,
109 numTransactions, true, onTestComplete)
cmumford 2015/08/03 17:31:34 Missing semicolon.
dmurph 2015/08/05 15:30:33 done.
110 }
111
112 function testRandomReadsAndWritesWithoutIndex(
113 numKeys, numReadsPerTransaction, numWritesPerTransaction,
114 numTransactions, onTestComplete) {
115 testRandomReadsAndWrites(numKeys, numReadsPerTransaction,
116 numWritesPerTransaction,
117 numTransactions, false, onTestComplete)
118 }
119
120
121 function testReadCacheWithIndex(numTransactions, onTestComplete) {
122 testReadCache(numTransactions, true, onTestComplete)
123 }
124
125 function testReadCacheWithoutIndex(numTransactions, onTestComplete) {
126 testReadCache(numTransactions, false, onTestComplete)
127 }
128
129 function testCursorSeeksWithIndex(numKeys, numSeeksPerTransaction,
130 numTransactions, onTestComplete) {
131 testCursorSeeks(numKeys, numSeeksPerTransaction, numTransactions,
132 true, onTestComplete)
133 }
134
135 function testCursorSeeksWithoutIndex(numKeys, numSeeksPerTransaction,
136 numTransactions, onTestComplete) {
137 testCursorSeeks(numKeys, numSeeksPerTransaction, numTransactions,
138 false, onTestComplete)
139 }
140
141
142
95 var currentTest = 0; 143 var currentTest = 0;
144 var testFilter;
145 var done = false;
96 146
97 function test() { 147 function test() {
148 done = false;
149 console.time('Action_IDBTest')
cmumford 2015/08/03 17:31:34 ;
dmurph 2015/08/05 15:30:33 Done.
98 runNextTest(); 150 runNextTest();
99 } 151 }
100 152
153
101 function runNextTest() { 154 function runNextTest() {
102 var filter = window.location.hash.slice(1);
103 var test, f; 155 var test, f;
cmumford 2015/08/03 17:31:34 This 'test' overrides the function above. Can you
dmurph 2015/08/05 15:30:33 sure.
104 while (currentTest < tests.length) { 156 while (currentTest < tests.length) {
105 test = tests[currentTest]; 157 test = tests[currentTest];
106 f = test.shift(); 158 f = test.shift();
107 if (!filter || f.name == filter) 159 if (!testFilter || f.name == testFilter)
108 break; 160 break;
109 ++currentTest; 161 ++currentTest;
110 } 162 }
111 163
112 if (currentTest < tests.length) { 164 if (currentTest < tests.length) {
113 test.push(runNextTest); 165 test.push(runNextTest);
114 f.apply(null, test); 166 f.apply(null, test);
115 ++currentTest; 167 ++currentTest;
116 } else { 168 } else {
117 onAllTestsComplete(); 169 onAllTestsComplete();
118 } 170 }
119 } 171 }
120 172
121 function onAllTestsComplete() { 173 function onAllTestsComplete() {
174 console.timeEnd('Action_IDBTest')
122 var overallDuration = window.performance.now() - overallTestStartTime; 175 var overallDuration = window.performance.now() - overallTestStartTime;
123 automation.addResult("OverallTestDuration", overallDuration); 176 automation.addResult("OverallTestDuration", overallDuration);
124 automation.setDone(); 177 automation.setDone();
178 done = true;
cmumford 2015/08/03 17:31:34 "done" never seems to be read anywhere?
dmurph 2015/08/05 15:30:33 It's read by the python to tell if the test is don
179 }
180
181 function testCreateAndDeleteDatabases(
182 numDatabases, numOpens, numKeys, numStores,
183 payloadLength, onTestComplete) {
184 var testName = getDisplayName(arguments);
185 assert(numOpens >= 1);
186 assert(numKeys >= 0);
187 assert(numStores >= 1);
188 var objectStoreNames = [];
189 for (var i=0; i < numStores; ++i) {
190 objectStoreNames.push("store " + i);
191 }
192 var value = stringOfLength(payloadLength);
193 function getValue() {
194 return value;
195 }
196
197 automation.setStatus("Creating databases.");
198 var startTime = window.performance.now();
199
200 var numCreated = 0;
201 for (var i = 0; i < numDatabases; i++) {
202 createDatabase(testName + i, objectStoreNames, onCreated, onError);
203 }
204
205 function onCreated(db) {
206 automation.setStatus("Constructing transactions.");
207 var transaction =
208 getTransaction(db, objectStoreNames, "readwrite",
209 function() { openLoop(db, numOpens); });
210 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue);
211 }
212
213 function openLoop(db, timesLeft) {
214 db.close();
215 if (timesLeft == 0) {
216 deleteDatabase(db.name, onDeleted);
217 return;
218 }
219 createDatabase(db.name, objectStoreNames,
220 function(db) { openLoop(db, timesLeft - 1); }, onError)
221 }
222
223 var numDeleted = 0;
224 function onDeleted() {
225 var duration = window.performance.now() - startTime;
226 automation.addResult(testName, duration);
227 automation.setStatus("Deleted database.");
228 if (++numDeleted == numDatabases) {
229 onTestComplete();
230 }
231 }
232 }
233
234 function testCreateKeysInStores(
235 numKeys, numStores, payloadLength, onTestComplete) {
236 var testName = getDisplayName(arguments);
237 assert(numKeys >= 0);
238 assert(numStores >= 1);
239 var objectStoreNames = [];
240 for (var i=0; i < numStores; ++i) {
241 objectStoreNames.push("store " + i);
242 }
243 var value = stringOfLength(payloadLength);
244 function getValue() {
245 return value;
246 }
247
248 automation.setStatus("Creating database.");
249 createDatabase(testName, objectStoreNames, onCreated, onError);
250
251 function onCreated(db) {
252 automation.setStatus("Constructing transaction.");
253 var completionFunc =
254 getCompletionFunc(db, testName, window.performance.now(),
255 onTestComplete);
256 var transaction =
257 getTransaction(db, objectStoreNames, "readwrite", completionFunc);
258 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue);
259 }
125 } 260 }
126 261
127 // This is the only test that includes database creation and deletion in its 262 // This is the only test that includes database creation and deletion in its
128 // results; the others just test specific operations. To see only the 263 // results; the others just test specific operations. To see only the
129 // creation/deletion without the specific operations used to build up the data 264 // creation/deletion without the specific operations used to build up the data
130 // in the object stores here, subtract off the results of 265 // in the object stores here, subtract off the results of
131 // testCreateKeysInStores. 266 // testCreateKeysInStores.
132 function testCreateAndDeleteDatabase( 267 function testCreateAndDeleteDatabase(
133 numKeys, numStores, payloadLength, onTestComplete) { 268 numKeys, numStores, payloadLength, onTestComplete) {
134 var testName = getDisplayName(arguments); 269 var testName = getDisplayName(arguments);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 request.onerror = onError; 714 request.onerror = onError;
580 request.onsuccess = function() { 715 request.onsuccess = function() {
581 var cursor = request.result; 716 var cursor = request.result;
582 if (cursor && first) { 717 if (cursor && first) {
583 first = false; 718 first = false;
584 cursor.continue(getKey(numKeys - 1)); 719 cursor.continue(getKey(numKeys - 1));
585 } 720 }
586 }; 721 };
587 } 722 }
588 } 723 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698