OLD | NEW |
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; |
| 7 var kDontUseIndex = false; |
| 8 var kReadKeysOnly = true; |
| 9 var kReadDataToo = false; |
| 10 var kWriteToo = true; |
| 11 var kDontWrite = false; |
| 12 |
| 13 var tests = [ |
| 14 // Create a single small item in a single object store. |
| 15 [testCreateKeysInStores, 1, 1, 1], |
| 16 // Create many small items in a single object store. |
| 17 [testCreateKeysInStores, 100, 1, 1], |
| 18 // Create a single small item in many object stores. |
| 19 [testCreateKeysInStores, 1, 100, 1], |
| 20 // Create many large items in a single object store. |
| 21 [testCreateKeysInStores, 100, 1, 10000], |
| 22 // Read a few random items in each of many transactions. |
| 23 [testRandomReadsAndWrites, 1000, 5, 0, 50, kDontUseIndex], |
| 24 // Read many random items in each of a few transactions. |
| 25 [testRandomReadsAndWrites, 1000, 50, 0, 5, kDontUseIndex], |
| 26 // Read many random items in each of a few transactions, in a large store. |
| 27 [testRandomReadsAndWrites, 5000, 50, 0, 5, kDontUseIndex], |
| 28 // Read a few random items from an index, in each of many transactions. |
| 29 [testRandomReadsAndWrites, 1000, 5, 0, 50, kUseIndex], |
| 30 // Read many random items from an index, in each of a few transactions. |
| 31 [testRandomReadsAndWrites, 1000, 50, 0, 5, kUseIndex], |
| 32 // Read many random items from an index, in each of a few transactions, in a |
| 33 // large store. |
| 34 [testRandomReadsAndWrites, 5000, 50, 0, 5, kUseIndex], |
| 35 // Read and write a few random items in each of many transactions. |
| 36 [testRandomReadsAndWrites, 1000, 5, 5, 50, kDontUseIndex], |
| 37 // Read and write a few random items, reading from an index, in each of many |
| 38 // transactions. |
| 39 [testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex], |
| 40 // Read a long, contiguous sequence of an object store via a cursor. |
| 41 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite], |
| 42 // Read a sequence of an object store via a cursor, writing |
| 43 // transformed values into another. |
| 44 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo], |
| 45 // Read a sequence of an index into an object store via a cursor. |
| 46 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite], |
| 47 // Read a sequence of an index into an object store via a key cursor. |
| 48 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite], |
| 49 // Make batches of random writes into a store, triggered by periodic setTimeout |
| 50 // calls. |
| 51 [testSporadicWrites, 5, 0], |
| 52 // Make large batches of random writes into a store, triggered by periodic |
| 53 // setTimeout calls. |
| 54 [testSporadicWrites, 50, 0], |
| 55 // Make batches of random writes into a store with many indices, triggered by |
| 56 // periodic setTimeout calls. |
| 57 [testSporadicWrites, 5, 10], |
| 58 // Make large batches of random writes into a store with many indices, triggered |
| 59 // by periodic setTimeout calls. |
| 60 [testSporadicWrites, 50, 10], |
| 61 // Create and delete an index on a store that already contains data [produces |
| 62 // a timing result for each of creation and deletion]. |
| 63 [testCreateAndDeleteIndex, 1000] |
| 64 ]; |
| 65 |
| 66 var currentTest = 0; |
| 67 |
| 68 function test() { |
| 69 runNextTest(); |
| 70 } |
| 71 |
| 72 function runNextTest() { |
| 73 if (currentTest < tests.length) { |
| 74 var test = tests[currentTest++].slice(); |
| 75 var f = test.shift(); |
| 76 test.push(runNextTest); |
| 77 f.apply(null, test); |
| 78 } else { |
| 79 onAllTestsComplete(); |
| 80 } |
| 81 } |
| 82 |
| 83 function onAllTestsComplete() { |
| 84 var overallDuration = Date.now() - overallTestStartTime; |
| 85 automation.addResult("OverallTestDuration", overallDuration); |
| 86 automation.setDone(); |
| 87 } |
6 | 88 |
7 function testCreateKeysInStores( | 89 function testCreateKeysInStores( |
8 numKeys, numStores, payloadLength, onTestComplete) { | 90 numKeys, numStores, payloadLength, onTestComplete) { |
9 var testName = getDisplayName(arguments); | 91 var testName = getDisplayName(arguments); |
10 assert(numKeys >= 0); | 92 assert(numKeys >= 0); |
11 assert(numStores >= 1); | 93 assert(numStores >= 1); |
12 var objectStoreNames = []; | 94 var objectStoreNames = []; |
13 for (var i=0; i < numStores; ++i) { | 95 for (var i=0; i < numStores; ++i) { |
14 objectStoreNames.push("store " + i); | 96 objectStoreNames.push("store " + i); |
15 } | 97 } |
16 var value = stringOfLength(payloadLength); | 98 var value = stringOfLength(payloadLength); |
17 function getValue() { | 99 function getValue() { |
18 return value; | 100 return value; |
19 } | 101 } |
20 | 102 |
| 103 automation.setStatus("Creating database."); |
| 104 createDatabase(testName, objectStoreNames, onCreated, onError); |
| 105 |
21 function onCreated(db) { | 106 function onCreated(db) { |
22 automation.setStatus("Constructing transaction."); | 107 automation.setStatus("Constructing transaction."); |
23 var completionFunc = | 108 var completionFunc = |
24 getCompletionFunc(testName, Date.now(), onTestComplete); | 109 getCompletionFunc(testName, Date.now(), onTestComplete); |
25 var transaction = | 110 var transaction = |
26 getTransaction(db, objectStoreNames, "readwrite", completionFunc); | 111 getTransaction(db, objectStoreNames, "readwrite", completionFunc); |
27 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue); | 112 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue); |
28 } | 113 } |
29 automation.setStatus("Creating database."); | |
30 createDatabase(testName, objectStoreNames, onCreated, onError); | |
31 } | 114 } |
32 | 115 |
33 function testRandomReadsAndWrites( | 116 function testRandomReadsAndWrites( |
34 numKeys, numReadsPerTransaction, numWritesPerTransaction, numTransactions, | 117 numKeys, numReadsPerTransaction, numWritesPerTransaction, numTransactions, |
35 useIndexForReads, onTestComplete) { | 118 useIndexForReads, onTestComplete) { |
36 var indexName; | 119 var indexName; |
37 if (useIndexForReads) | 120 if (useIndexForReads) |
38 indexName = "index"; | 121 indexName = "index"; |
39 var testName = getDisplayName(arguments); | 122 var testName = getDisplayName(arguments); |
40 var numTransactionsLeft = numTransactions; | 123 var numTransactionsLeft = numTransactions; |
41 var objectStoreNames = ["store"]; | 124 var objectStoreNames = ["store"]; |
42 var numTransactionsRunning; | 125 var numTransactionsRunning; |
43 | 126 |
| 127 automation.setStatus("Creating database."); |
| 128 var options; |
| 129 if (useIndexForReads) { |
| 130 options = [{ |
| 131 indexName: indexName, |
| 132 indexKeyPath: "", |
| 133 indexIsUnique: false, |
| 134 indexIsMultiEntry: false, |
| 135 }]; |
| 136 } |
| 137 createDatabase(testName, objectStoreNames, onCreated, onError, options); |
| 138 |
44 function onCreated(db) { | 139 function onCreated(db) { |
45 automation.setStatus("Setting up test database."); | 140 automation.setStatus("Setting up test database."); |
46 var transaction = getTransaction(db, objectStoreNames, "readwrite", | 141 var transaction = getTransaction(db, objectStoreNames, "readwrite", |
47 function() { onSetupComplete(db); }); | 142 function() { onSetupComplete(db); }); |
48 putLinearValues(transaction, objectStoreNames, numKeys, null, | 143 putLinearValues(transaction, objectStoreNames, numKeys, null, |
49 function () { return "test value"; }); | 144 function () { return "test value"; }); |
50 } | 145 } |
| 146 |
51 var completionFunc; | 147 var completionFunc; |
52 function onSetupComplete(db) { | 148 function onSetupComplete(db) { |
53 automation.setStatus("Setup complete."); | 149 automation.setStatus("Setup complete."); |
54 completionFunc = getCompletionFunc(testName, Date.now(), onTestComplete); | 150 completionFunc = getCompletionFunc(testName, Date.now(), onTestComplete); |
55 runOneBatch(db); | 151 runOneBatch(db); |
56 } | 152 } |
57 | 153 |
58 function runOneBatch(db) { | 154 function runOneBatch(db) { |
59 if (numTransactionsLeft <= 0) { | 155 if (numTransactionsLeft <= 0) { |
60 return; | 156 return; |
(...skipping 11 matching lines...) Expand all Loading... |
72 } else { | 168 } else { |
73 runOneBatch(db); | 169 runOneBatch(db); |
74 } | 170 } |
75 }); | 171 }); |
76 | 172 |
77 getRandomValues(transaction, objectStoreNames, numReadsPerTransaction, | 173 getRandomValues(transaction, objectStoreNames, numReadsPerTransaction, |
78 numKeys, indexName); | 174 numKeys, indexName); |
79 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction, | 175 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction, |
80 numKeys); | 176 numKeys); |
81 } | 177 } |
82 | |
83 automation.setStatus("Creating database."); | |
84 var options; | |
85 if (useIndexForReads) { | |
86 options = [{ | |
87 indexName: indexName, | |
88 indexKeyPath: "", | |
89 indexIsUnique: false, | |
90 indexIsMultiEntry: false, | |
91 }]; | |
92 } | |
93 createDatabase(testName, objectStoreNames, onCreated, onError, options); | |
94 } | 178 } |
95 | 179 |
96 function testCreateAndDeleteIndex(numKeys, onTestComplete) { | 180 function testCreateAndDeleteIndex(numKeys, onTestComplete) { |
97 var testName = getDisplayName(arguments); | 181 var testName = getDisplayName(arguments); |
98 var objectStoreNames = ["store"]; | 182 var objectStoreNames = ["store"]; |
99 function getValue(i) { | 183 |
100 return { firstName: i + " first name", lastName: i + " last name" }; | 184 automation.setStatus("Creating database."); |
101 } | 185 createDatabase(testName, objectStoreNames, onCreated, onError); |
102 | 186 |
103 var startTime; | 187 var startTime; |
104 function onCreated(db) { | 188 function onCreated(db) { |
105 automation.setStatus("Initializing data."); | 189 automation.setStatus("Initializing data."); |
106 var transaction = getTransaction(db, objectStoreNames, "readwrite", | 190 var transaction = getTransaction(db, objectStoreNames, "readwrite", |
107 function() { onPopulated(db); }); | 191 function() { onPopulated(db); }); |
108 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue); | 192 putLinearValues(transaction, objectStoreNames, numKeys, null, getValue); |
109 } | 193 } |
110 | 194 |
| 195 function getValue(i) { |
| 196 return { firstName: i + " first name", lastName: i + " last name" }; |
| 197 } |
| 198 |
111 function onPopulated(db) { | 199 function onPopulated(db) { |
112 db.close(); | 200 db.close(); |
113 automation.setStatus("Building index."); | 201 automation.setStatus("Building index."); |
114 startTime = Date.now(); | 202 startTime = Date.now(); |
115 var f = function(objectStore) { | 203 var f = function(objectStore) { |
116 objectStore.createIndex("index", "firstName", {unique: true}); | 204 objectStore.createIndex("index", "firstName", {unique: true}); |
117 }; | 205 }; |
118 alterObjectStores(testName, objectStoreNames, f, onIndexCreated, onError); | 206 alterObjectStores(testName, objectStoreNames, f, onIndexCreated, onError); |
119 } | 207 } |
120 | 208 |
121 var completionFunc; | 209 var completionFunc; |
122 function onIndexCreated(db) { | 210 function onIndexCreated(db) { |
123 db.close(); | 211 db.close(); |
124 var indexCreationCompleteTime = Date.now(); | 212 var indexCreationCompleteTime = Date.now(); |
125 automation.addResult("testCreateIndex", | 213 automation.addResult("testCreateIndex", |
126 indexCreationCompleteTime - startTime); | 214 indexCreationCompleteTime - startTime); |
127 completionFunc = getCompletionFunc("testDeleteIndex", | 215 completionFunc = getCompletionFunc("testDeleteIndex", |
128 indexCreationCompleteTime, onTestComplete); | 216 indexCreationCompleteTime, onTestComplete); |
129 var f = function(objectStore) { | 217 var f = function(objectStore) { |
130 objectStore.deleteIndex("index"); | 218 objectStore.deleteIndex("index"); |
131 }; | 219 }; |
132 automation.setStatus("Deleting index."); | 220 automation.setStatus("Deleting index."); |
133 alterObjectStores(testName, objectStoreNames, f, completionFunc, onError); | 221 alterObjectStores(testName, objectStoreNames, f, completionFunc, onError); |
134 } | 222 } |
135 | |
136 automation.setStatus("Creating database."); | |
137 createDatabase(testName, objectStoreNames, onCreated, onError); | |
138 } | 223 } |
139 | 224 |
140 // TODO: Add a version that writes back to the same store, to see how that | 225 // TODO: Add a version that writes back to the same store, to see how that |
141 // affects cursor speed w.r.t. invalidated caches. | 226 // affects cursor speed w.r.t. invalidated caches. |
142 function testCursorReadsAndRandomWrites( | 227 function testCursorReadsAndRandomWrites( |
143 readKeysOnly, useIndexForReads, writeToAnotherStore, onTestComplete) { | 228 readKeysOnly, useIndexForReads, writeToAnotherStore, onTestComplete) { |
144 // There's no key cursor unless you're reading from an index. | 229 // There's no key cursor unless you're reading from an index. |
145 assert(useIndexForReads || !readKeysOnly); | 230 assert(useIndexForReads || !readKeysOnly); |
146 // If we're writing to another store, having an index would constrain our | 231 // If we're writing to another store, having an index would constrain our |
147 // writes, as we create both object stores with the same configurations. | 232 // writes, as we create both object stores with the same configurations. |
(...skipping 11 matching lines...) Expand all Loading... |
159 indexName = "index"; | 244 indexName = "index"; |
160 getKeyForRead = function(i) { | 245 getKeyForRead = function(i) { |
161 // This depends on the implementations of getValuesFromCursor and | 246 // This depends on the implementations of getValuesFromCursor and |
162 // getObjectValue. We reverse the order of the iteration here so that | 247 // getObjectValue. We reverse the order of the iteration here so that |
163 // setting up bounds from k to k+n with n>0 works. Without this reversal, | 248 // setting up bounds from k to k+n with n>0 works. Without this reversal, |
164 // the upper bound is below the lower bound. | 249 // the upper bound is below the lower bound. |
165 return getBackwardIndexKey(numKeys - i); | 250 return getBackwardIndexKey(numKeys - i); |
166 } | 251 } |
167 } | 252 } |
168 | 253 |
| 254 automation.setStatus("Creating database."); |
| 255 var options; |
| 256 if (useIndexForReads) { |
| 257 options = [{ |
| 258 indexName: indexName, |
| 259 indexKeyPath: "lastName", // depends on getBackwardIndexKey() |
| 260 indexIsUnique: true, |
| 261 indexIsMultiEntry: false, |
| 262 }]; |
| 263 } |
| 264 createDatabase(testName, objectStoreNames, onCreated, onError, options); |
| 265 |
169 function onCreated(db) { | 266 function onCreated(db) { |
170 automation.setStatus("Setting up test database."); | 267 automation.setStatus("Setting up test database."); |
171 var transaction = getTransaction(db, objectStoreNames, "readwrite", | 268 var transaction = getTransaction(db, objectStoreNames, "readwrite", |
172 function() { onSetupComplete(db); }); | 269 function() { onSetupComplete(db); }); |
173 putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey, | 270 putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey, |
174 getObjectValue); | 271 getObjectValue); |
175 } | 272 } |
176 function onSetupComplete(db) { | 273 function onSetupComplete(db) { |
177 automation.setStatus("Setup complete."); | 274 automation.setStatus("Setup complete."); |
178 var completionFunc = | 275 var completionFunc = |
179 getCompletionFunc(testName, Date.now(), onTestComplete); | 276 getCompletionFunc(testName, Date.now(), onTestComplete); |
180 var mode = "readonly"; | 277 var mode = "readonly"; |
181 if (writeToAnotherStore) | 278 if (writeToAnotherStore) |
182 mode = "readwrite"; | 279 mode = "readwrite"; |
183 var transaction = | 280 var transaction = |
184 getTransaction(db, objectStoreNames, mode, completionFunc); | 281 getTransaction(db, objectStoreNames, mode, completionFunc); |
185 | 282 |
186 getValuesFromCursor( | 283 getValuesFromCursor( |
187 transaction, objectStoreNames[0], numReadsPerTransaction, numKeys, | 284 transaction, objectStoreNames[0], numReadsPerTransaction, numKeys, |
188 indexName, getKeyForRead, readKeysOnly, objectStoreNames[1]); | 285 indexName, getKeyForRead, readKeysOnly, objectStoreNames[1]); |
189 } | 286 } |
190 | |
191 automation.setStatus("Creating database."); | |
192 var options; | |
193 if (useIndexForReads) { | |
194 options = [{ | |
195 indexName: indexName, | |
196 indexKeyPath: "lastName", // depends on getBackwardIndexKey() | |
197 indexIsUnique: true, | |
198 indexIsMultiEntry: false, | |
199 }]; | |
200 } | |
201 createDatabase(testName, objectStoreNames, onCreated, onError, options); | |
202 } | 287 } |
203 | 288 |
204 function testSporadicWrites( | 289 function testSporadicWrites( |
205 numWritesPerTransaction, numIndices, onTestComplete) { | 290 numWritesPerTransaction, numIndices, onTestComplete) { |
206 var numKeys = 1000; | 291 var numKeys = 1000; |
207 // With 30 transactions, spaced 50ms apart, we'll need at least 1.5s. | 292 // With 30 transactions, spaced 50ms apart, we'll need at least 1.5s. |
208 var numTransactions = 30; | 293 var numTransactions = 30; |
209 var delayBetweenBatches = 50; | 294 var delayBetweenBatches = 50; |
210 var indexName; | 295 var indexName; |
211 var testName = getDisplayName(arguments); | 296 var testName = getDisplayName(arguments); |
212 var numTransactionsLeft = numTransactions; | 297 var numTransactionsLeft = numTransactions; |
213 var objectStoreNames = ["store"]; | 298 var objectStoreNames = ["store"]; |
214 var numTransactionsRunning = 0; | 299 var numTransactionsRunning = 0; |
215 | 300 |
216 var getValue = getSimpleValue; | 301 var getValue = getSimpleValue; |
217 if (numIndices) | 302 if (numIndices) |
218 getValue = function (i) { return getNFieldObjectValue(i, numIndices); }; | 303 getValue = function (i) { return getNFieldObjectValue(i, numIndices); }; |
219 | 304 |
| 305 automation.setStatus("Creating database."); |
| 306 var options = []; |
| 307 for (var i=0; i < numIndices; ++i) { |
| 308 var o = {}; |
| 309 o.indexName = "index " + i; |
| 310 o.indexKeyPath = getNFieldName(i); |
| 311 o.indexIsUnique = false; |
| 312 o.indexIsMultiEntry = false; |
| 313 options.push(o); |
| 314 } |
| 315 createDatabase(testName, objectStoreNames, onCreated, onError, options); |
| 316 |
220 function onCreated(db) { | 317 function onCreated(db) { |
221 automation.setStatus("Setting up test database."); | 318 automation.setStatus("Setting up test database."); |
222 var transaction = getTransaction(db, objectStoreNames, "readwrite", | 319 var transaction = getTransaction(db, objectStoreNames, "readwrite", |
223 function() { onSetupComplete(db); }); | 320 function() { onSetupComplete(db); }); |
224 putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey, | 321 putLinearValues(transaction, objectStoreNames, numKeys, getSimpleKey, |
225 getValue); | 322 getValue); |
226 } | 323 } |
227 var completionFunc; | 324 var completionFunc; |
228 function onSetupComplete(db) { | 325 function onSetupComplete(db) { |
229 automation.setStatus("Setup complete."); | 326 automation.setStatus("Setup complete."); |
(...skipping 15 matching lines...) Expand all Loading... |
245 } | 342 } |
246 | 343 |
247 var mode = "readonly"; | 344 var mode = "readonly"; |
248 if (numWritesPerTransaction) | 345 if (numWritesPerTransaction) |
249 mode = "readwrite"; | 346 mode = "readwrite"; |
250 | 347 |
251 var transaction = getTransaction(db, objectStoreNames, mode, batchComplete); | 348 var transaction = getTransaction(db, objectStoreNames, mode, batchComplete); |
252 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction, | 349 putRandomValues(transaction, objectStoreNames, numWritesPerTransaction, |
253 numKeys); | 350 numKeys); |
254 } | 351 } |
255 | |
256 automation.setStatus("Creating database."); | |
257 var options = []; | |
258 for (var i=0; i < numIndices; ++i) { | |
259 var o = {}; | |
260 o.indexName = "index " + i; | |
261 o.indexKeyPath = getNFieldName(i); | |
262 o.indexIsUnique = false; | |
263 o.indexIsMultiEntry = false; | |
264 options.push(o); | |
265 } | |
266 createDatabase(testName, objectStoreNames, onCreated, onError, options); | |
267 } | 352 } |
268 | |
269 var kUseIndex = true; | |
270 var kDontUseIndex = false; | |
271 var kReadKeysOnly = true; | |
272 var kReadDataToo = false; | |
273 var kWriteToo = true; | |
274 var kDontWrite = false; | |
275 | |
276 var tests = [ | |
277 // Create a single small item in a single object store. | |
278 [testCreateKeysInStores, 1, 1, 1], | |
279 // Create many small items in a single object store. | |
280 [testCreateKeysInStores, 100, 1, 1], | |
281 // Create a single small item in many object stores. | |
282 [testCreateKeysInStores, 1, 100, 1], | |
283 // Create many large items in a single object store. | |
284 [testCreateKeysInStores, 100, 1, 10000], | |
285 // Read a few random items in each of many transactions. | |
286 [testRandomReadsAndWrites, 1000, 5, 0, 50, kDontUseIndex], | |
287 // Read many random items in each of a few transactions. | |
288 [testRandomReadsAndWrites, 1000, 50, 0, 5, kDontUseIndex], | |
289 // Read many random items in each of a few transactions, in a large store. | |
290 [testRandomReadsAndWrites, 5000, 50, 0, 5, kDontUseIndex], | |
291 // Read a few random items from an index, in each of many transactions. | |
292 [testRandomReadsAndWrites, 1000, 5, 0, 50, kUseIndex], | |
293 // Read many random items from an index, in each of a few transactions. | |
294 [testRandomReadsAndWrites, 1000, 50, 0, 5, kUseIndex], | |
295 // Read many random items from an index, in each of a few transactions, in a | |
296 // large store. | |
297 [testRandomReadsAndWrites, 5000, 50, 0, 5, kUseIndex], | |
298 // Read and write a few random items in each of many transactions. | |
299 [testRandomReadsAndWrites, 1000, 5, 5, 50, kDontUseIndex], | |
300 // Read and write a few random items, reading from an index, in each of many | |
301 // transactions. | |
302 [testRandomReadsAndWrites, 1000, 5, 5, 50, kUseIndex], | |
303 // Read a long, contiguous sequence of an object store via a cursor. | |
304 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kDontWrite], | |
305 // Read a sequence of an object store via a cursor, writing | |
306 // transformed values into another. | |
307 [testCursorReadsAndRandomWrites, kReadDataToo, kDontUseIndex, kWriteToo], | |
308 // Read a sequence of an index into an object store via a cursor. | |
309 [testCursorReadsAndRandomWrites, kReadDataToo, kUseIndex, kDontWrite], | |
310 // Read a sequence of an index into an object store via a key cursor. | |
311 [testCursorReadsAndRandomWrites, kReadKeysOnly, kUseIndex, kDontWrite], | |
312 // Make batches of random writes into a store, triggered by periodic setTimeout | |
313 // calls. | |
314 [testSporadicWrites, 5, 0], | |
315 // Make large batches of random writes into a store, triggered by periodic | |
316 // setTimeout calls. | |
317 [testSporadicWrites, 50, 0], | |
318 // Make batches of random writes into a store with many indices, triggered by | |
319 // periodic setTimeout calls. | |
320 [testSporadicWrites, 5, 10], | |
321 // Make large batches of random writes into a store with many indices, triggered | |
322 // by periodic setTimeout calls. | |
323 [testSporadicWrites, 50, 10], | |
324 // Create and delete an index on a store that already contains data [produces | |
325 // a timing result for each of creation and deletion]. | |
326 [testCreateAndDeleteIndex, 1000] | |
327 ]; | |
328 | |
329 var currentTest = 0; | |
330 | |
331 function runNextTest() { | |
332 if (currentTest < tests.length) { | |
333 var test = tests[currentTest++].slice(); | |
334 var f = test.shift(); | |
335 test.push(runNextTest); | |
336 f.apply(null, test); | |
337 } else { | |
338 onAllTestsComplete(); | |
339 } | |
340 } | |
341 | |
342 function onAllTestsComplete() { | |
343 var overallDuration = Date.now() - overallTestStartTime; | |
344 automation.addResult("OverallTestDuration", overallDuration); | |
345 automation.setDone(); | |
346 } | |
347 | |
348 function test() { | |
349 runNextTest(); | |
350 } | |
OLD | NEW |