OLD | NEW |
---|---|
(Empty) | |
1 var overallTestStartTime = Date.now(); | |
2 | |
3 function testCreateKeysInStores( | |
4 numKeys, numStores, payloadLength, onTestComplete) { | |
5 var testName = "testCreateKeysInStores_" + numKeys + "_" + numStores + "_" + | |
6 payloadLength; | |
7 assert(numKeys >= 0); | |
8 assert(numStores >= 1); | |
9 var objectStoreNames = []; | |
10 for (var i=0; i < numStores; ++i) { | |
11 objectStoreNames.push("store " + i); | |
12 } | |
13 var value = stringOfLength(payloadLength); | |
14 var start; | |
15 | |
16 function onCreated(db) { | |
17 automation.setStatus("Constructing transaction."); | |
18 start = Date.now(); // Ignore the setup time for this test. | |
19 var transaction = getTransaction(db, objectStoreNames, "readwrite", | |
20 function() { onTransactionComplete(db); }); | |
21 for (var i in objectStoreNames) { | |
22 var os = transaction.objectStore(objectStoreNames[i]); | |
23 assert(os); | |
24 for (var j = 0; j < numKeys; ++j) { | |
25 os.put("key " + j, value); | |
jsbell
2012/06/21 00:04:16
This is measuring three distinct things:
* Time ta
| |
26 } | |
27 } | |
28 } | |
29 function onTransactionComplete(db) { | |
30 var duration = Date.now() - start; | |
31 // Ignore the cleanup time for this test. | |
32 automation.addResult(testName, duration); | |
33 automation.setStatus("Deleting."); | |
34 deleteDatabase(db, onDeleted); | |
35 } | |
36 function onDeleted() { | |
37 automation.setStatus("Deleted."); | |
38 onTestComplete(); | |
39 } | |
40 automation.setStatus("Creating."); | |
41 createDatabase(testName, objectStoreNames, onCreated, onError); | |
42 } | |
43 | |
44 var tests = [ | |
45 [testCreateKeysInStores, 1, 1, 1], | |
46 [testCreateKeysInStores, 100, 1, 1], | |
47 [testCreateKeysInStores, 1, 100, 1], | |
48 [testCreateKeysInStores, 100, 1, 100000] | |
49 ]; | |
50 | |
51 var currentTest = 0; | |
52 | |
53 function runNextTest() { | |
54 if (currentTest < tests.length) { | |
55 var test = tests[currentTest++].slice(); | |
56 var f = test.shift(); | |
57 test.push(runNextTest); | |
58 f.apply(null, test); | |
59 } else { | |
60 onAllTestsComplete(); | |
61 } | |
62 } | |
63 | |
64 function onAllTestsComplete() { | |
65 var overallDuration = Date.now() - overallTestStartTime; | |
66 automation.addResult("OverallTestDuration", overallDuration); | |
67 automation.setDone(); | |
68 } | |
69 | |
70 function test() { | |
71 runNextTest(); | |
72 } | |
OLD | NEW |