Enable HAVE_AVFOUNDATION_VIDEO_OUTPUT on PLATFORM(IOSMAC)
[WebKit-https.git] / PerformanceTests / IndexedDB / large-number-of-inserts-responsiveness.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-responsiveness-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         largestDelay = 0;
29         testGenerator = null;
30         PerfTestRunner.gc();
31         ++currentIteration;
32     }
33 });
34
35 function startIteration()
36 {
37     testGenerator = runIteration();
38     nextStep();
39 }
40
41 function nextStep()
42 {
43     testGenerator.next();
44 }
45
46 var numberOfObjects = 50000;
47 var objectsToInsert = new Array(numberOfObjects);
48 for (var i = 0; i < numberOfObjects; ++i) {
49     objectsToInsert[i] = { data: Math.random() };
50     objectsToInsert[i].id = 'object_' + i;
51 }
52
53 function *runIteration()
54 {
55     var openRequest = indexedDB.open(databasePrefix + currentIteration);
56     openRequest.onupgradeneeded = function(event) {
57         db = event.target.result;
58         db.createObjectStore('objects', {keyPath: 'id'});
59     }
60     openRequest.onsuccess = nextStep;
61
62     yield;
63
64     var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
65     objectStore.transaction.oncomplete = nextStep;
66     for (var i = 0; i < numberOfObjects; ++i)
67         objectStore.put(objectsToInsert[i]);
68
69     PerfTestRunner.startCheckingResponsiveness();
70
71     yield;
72
73     PerfTestRunner.stopCheckingResponsiveness();
74     
75     if (!PerfTestRunner.measureValueAsync(PerfTestRunner.longestResponsivenessDelay()))
76         return;
77
78     setTimeout(startIteration, 0);
79 }
80
81 </script>
82 </body>
83 </html>