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

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

Issue 10854046: Add cache test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add cache test length variants 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
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 window.indexedDB = window.indexedDB || window.webkitIndexedDB || 5 window.indexedDB = window.indexedDB || window.webkitIndexedDB ||
6 window.mozIndexedDB || window.msIndexedDB; 6 window.mozIndexedDB || window.msIndexedDB;
7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange; 7 window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
8 8
9 var automation = { 9 var automation = {
10 results: {} 10 results: {}
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 for (var i in objectStoreNames) { 304 for (var i in objectStoreNames) {
305 var os = transaction.objectStore(objectStoreNames[i]); 305 var os = transaction.objectStore(objectStoreNames[i]);
306 for (var j = 0; j < numPuts; ++j) { 306 for (var j = 0; j < numPuts; ++j) {
307 var rand = Math.floor(Math.random() * numKeys); 307 var rand = Math.floor(Math.random() * numKeys);
308 var request = os.put(getValue(rand), getKey(rand)); 308 var request = os.put(getValue(rand), getKey(rand));
309 request.onerror = onError; 309 request.onerror = onError;
310 } 310 }
311 } 311 }
312 } 312 }
313 313
314 function getSpecificValues(transaction, objectStoreNames, indexName, keys) {
315 for (var i in objectStoreNames) {
316 var os = transaction.objectStore(objectStoreNames[i]);
317 var source = os;
318 if (indexName)
319 source = source.index(indexName);
320 for (var j = 0; j < keys.length; ++j) {
321 var request = source.get(keys[j]);
322 request.onerror = onError;
jsbell 2012/08/09 17:58:18 This doesn't verify that a value was returned (suc
ericu 2012/08/15 17:56:22 Added it in a couple of places.
323 }
324 }
325 }
326
314 // getKey should be deterministic, as we assume that a cursor that starts at 327 // getKey should be deterministic, as we assume that a cursor that starts at
315 // getKey(X) and runs through getKey(X + K) has exactly K values available. 328 // getKey(X) and runs through getKey(X + K) has exactly K values available.
316 // This is annoying to guarantee generally when using an index, so we avoid both 329 // This is annoying to guarantee generally when using an index, so we avoid both
317 // ends of the key space just in case and use simple indices. 330 // ends of the key space just in case and use simple indices.
318 // TODO(ericu): Figure out if this can be simplified and we can remove uses of 331 // TODO(ericu): Figure out if this can be simplified and we can remove uses of
319 // getObjectValue in favor of getNFieldObjectValue. 332 // getObjectValue in favor of getNFieldObjectValue.
320 function getValuesFromCursor( 333 function getValuesFromCursor(
321 transaction, inputObjectStoreName, numReads, numKeys, indexName, getKey, 334 transaction, inputObjectStoreName, numReads, numKeys, indexName, getKey,
322 readKeysOnly, outputObjectStoreName) { 335 readKeysOnly, outputObjectStoreName) {
323 assert(2 * numReads < numKeys); 336 assert(2 * numReads < numKeys);
(...skipping 29 matching lines...) Expand all
353 // outside its range. 366 // outside its range.
354 oos.put(cursor.value, numKeys + Math.random()); 367 oos.put(cursor.value, numKeys + Math.random());
355 values.push({key: cursor.key, value: cursor.value}); 368 values.push({key: cursor.key, value: cursor.value});
356 cursor.continue(); 369 cursor.continue();
357 } else { 370 } else {
358 assert(!numReadsLeft); 371 assert(!numReadsLeft);
359 } 372 }
360 } 373 }
361 request.onerror = onError; 374 request.onerror = onError;
362 } 375 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | chrome/test/data/indexeddb/perf_test.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698