[MotionMark] The text "kkkj" is causing Firefox console warning: `unreachable code...
[WebKit-https.git] / PerformanceTests / IndexedDB / large-number-of-inserts.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/runner.js"></script>
5 <script>
6
7 var iterationCount = 20;
8 var numberDeleted = 0;
9
10 // Delete all databases for the test ahead of time.
11 var databasePrefix = "large-number-of-inserts-DB-";
12 for (var i = 0; i < iterationCount + 1; ++i) {
13     indexedDB.deleteDatabase(databasePrefix + i).onsuccess = function() {
14         if (++numberDeleted == iterationCount)
15             startIteration();
16     }
17 }
18
19 var testGenerator = null;
20 var db = null;
21 var currentIteration = 0;
22
23 PerfTestRunner.prepareToMeasureValuesAsync({
24     customIterationCount: iterationCount,
25     unit: 'ms',
26     done: function () {
27         db = null;
28         testGenerator = null;
29         PerfTestRunner.gc();
30         ++currentIteration;
31     }
32 });
33
34 function startIteration()
35 {
36     testGenerator = runIteration();
37     nextStep();
38 }
39
40 function nextStep()
41 {
42     testGenerator.next();
43 }
44
45 var numberOfObjects = 100000;
46 var objectsToInsert = new Array(numberOfObjects);
47 for (var i = 0; i < numberOfObjects; ++i) {
48     objectsToInsert[i] = { data: Math.random() };
49     objectsToInsert[i].id = 'object_' + i;
50 }
51
52 function *runIteration()
53 {
54     var openRequest = indexedDB.open(databasePrefix + currentIteration);
55     openRequest.onupgradeneeded = function(event) {
56         db = event.target.result;
57         db.createObjectStore('objects', {keyPath: 'id'});
58     }
59     openRequest.onsuccess = nextStep;
60
61     yield;
62
63     var startTime = PerfTestRunner.now();
64
65     var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
66     objectStore.transaction.oncomplete = nextStep;
67     for (var i = 0; i < numberOfObjects; ++i)
68         objectStore.put(objectsToInsert[i]);
69
70     yield;
71
72     if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
73         return;
74
75     setTimeout(startIteration, 0);
76 }
77
78 </script>
79 </body>
80 </html>