Enable HAVE_AVFOUNDATION_VIDEO_OUTPUT on PLATFORM(IOSMAC)
[WebKit-https.git] / PerformanceTests / IndexedDB / objectstore-get.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/runner.js"></script>
5 <script>
6
7 // Delete database(s) for the test ahead of time.
8 var databaseName = "objectstore-get-DB";
9 indexedDB.deleteDatabase(databaseName).onsuccess = function() {
10     startIteration();
11 }
12
13 var testGenerator = null;
14 var db = null;
15 var transaction = null;
16
17 PerfTestRunner.prepareToMeasureValuesAsync({
18     customIterationCount: 20,
19     unit: 'ms',
20     done: function () {
21         transaction = null;
22         db = null;
23         testGenerator = null;
24         PerfTestRunner.gc();
25     }
26 });
27
28 function startIteration()
29 {
30     testGenerator = runIteration();
31     nextStep();
32 }
33
34 function nextStep()
35 {
36     testGenerator.next();
37 }
38
39 var numberOfEntries = 5000;
40
41 function *runIteration()
42 {
43     var openRequest = indexedDB.open(databaseName);
44     openRequest.onupgradeneeded = function(event) {
45         db = event.target.result;
46         var objectStore = db.createObjectStore('store');
47         for (var i = 0; i < numberOfEntries; ++i)
48            objectStore.put("index" + i, i);
49     }
50     openRequest.onsuccess = nextStep;
51
52     yield;
53
54     var startTime = PerfTestRunner.now();
55
56     var objectStore = db.transaction('store').objectStore('store');
57     var completedGets = 0;
58     for (var i = 0; i < numberOfEntries; ++i)
59     {
60         
61         objectStore.get(i).onsuccess = (function (j) {
62             return function(event) {
63                 if (event.target.result != ("index" + j))
64                     alert("Expected 'index" + j + "', got '" + event.target.result + "'");
65
66                 if (++completedGets == numberOfEntries)
67                     nextStep();
68             }
69         })(i);
70     }
71
72     yield;
73
74     if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
75         return;
76
77     setTimeout(startIteration, 0);
78 }
79 </script>
80 </body>
81 </html>