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

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

Issue 10828119: Reorder declaration vs. usage, build padToWidth on top of stringOfLength. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | 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 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // TODO(ericu): Make test errors delete the database automatically. 186 // TODO(ericu): Make test errors delete the database automatically.
187 return getDisplayName.caller.name + "_" + 187 return getDisplayName.caller.name + "_" +
188 Array.prototype.slice.call(args, 0, args.length - 1).join("_"); 188 Array.prototype.slice.call(args, 0, args.length - 1).join("_");
189 } 189 }
190 190
191 // Pad a string [or object convertible to a string] to a fixed width; use this 191 // Pad a string [or object convertible to a string] to a fixed width; use this
192 // to have numeric strings sort properly. 192 // to have numeric strings sort properly.
193 function padToWidth(s, width) { 193 function padToWidth(s, width) {
194 s = String(s); 194 s = String(s);
195 assert(s.length <= width); 195 assert(s.length <= width);
196 while (s.length < width) { 196 if (s.length < width) {
197 s = "0" + s; 197 s = stringOfLength(width - s.length, '0') + s;
198 } 198 }
199 return s; 199 return s;
200 } 200 }
201 201
202 function stringOfLength(n, c) {
203 if (c == null)
204 c = 'X';
205 assert(n > 0);
206 assert(n == Math.floor(n));
207 return new Array(n + 1).join(c);
208 }
209
202 function getSimpleKey(i) { 210 function getSimpleKey(i) {
203 return "key " + padToWidth(i, 10); 211 return "key " + padToWidth(i, 10);
204 } 212 }
205 213
206 function getSimpleValue(i) { 214 function getSimpleValue(i) {
207 return "value " + padToWidth(i, 10); 215 return "value " + padToWidth(i, 10);
208 } 216 }
209 217
210 function getForwardIndexKey(i) { 218 function getForwardIndexKey(i) {
211 return i; 219 return i;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (oos) // Put in random order for maximum difficulty. 335 if (oos) // Put in random order for maximum difficulty.
328 oos.put(cursor.value, Math.random()); 336 oos.put(cursor.value, Math.random());
329 values.push({key: cursor.key, value: cursor.value}); 337 values.push({key: cursor.key, value: cursor.value});
330 cursor.continue(); 338 cursor.continue();
331 } else { 339 } else {
332 assert(!numReadsLeft); 340 assert(!numReadsLeft);
333 } 341 }
334 } 342 }
335 request.onerror = onError; 343 request.onerror = onError;
336 } 344 }
337
338
339 function stringOfLength(n) {
340 assert(n > 0);
341 assert(n == Math.floor(n));
342 return new Array(n + 1).join('0');
343 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/indexeddb/perf_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698