Enable HAVE_AVFOUNDATION_VIDEO_OUTPUT on PLATFORM(IOSMAC)
[WebKit-https.git] / PerformanceTests / IndexedDB / large-binary-keys.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 var quota = 500 * 1024 * 1024; //500MB
11 if (window.testRunner)
12     testRunner.setIDBPerOriginQuota(quota);
13
14 // Delete all databases for the test ahead of time.
15 var databasePrefix = "large-string-keys-DB-";
16 for (var i = 0; i < iterationCount + 1; ++i) {
17     indexedDB.deleteDatabase(databasePrefix + i).onsuccess = function() {
18         if (++numberDeleted == iterationCount)
19             startIteration();
20     }
21 }
22
23 var testGenerator = null;
24 var db = null;
25 var currentIteration = 0;
26
27 PerfTestRunner.prepareToMeasureValuesAsync({
28     customIterationCount: iterationCount,
29     unit: 'ms',
30     done: function () {
31         db = null;
32         testGenerator = null;
33         PerfTestRunner.gc();
34         ++currentIteration;
35     }
36 });
37
38 function startIteration()
39 {
40     testGenerator = runIteration();
41     nextStep();
42 }
43
44 function nextStep()
45 {
46     testGenerator.next();
47 }
48
49 var baseString;
50 for (var i = 0; i < 100000; ++i)
51     baseString += "abcdefghijklmnopqrstuvwxyz";
52
53 var numberOfInserts = 50;
54 var array = new Array(numberOfInserts);
55 for (var i = 0; i < numberOfInserts; ++i) {
56     array[i] = new ArrayBuffer(2097152);
57     var view = new Int32Array(array[i]);
58     view[view.length - 1] = i;
59 }
60
61 function *runIteration()
62 {
63     var openRequest = indexedDB.open(databasePrefix + currentIteration);
64     openRequest.onupgradeneeded = function(event) {
65         db = event.target.result;
66         db.createObjectStore('arrays');
67     }
68     openRequest.onsuccess = nextStep;
69
70     yield;
71
72     var startTime = PerfTestRunner.now();
73
74     var objectStore = db.transaction('arrays', 'readwrite').objectStore('arrays');
75     objectStore.transaction.oncomplete = nextStep;
76
77     for (var i = 0; i < numberOfInserts; ++i)
78         objectStore.put("Some value!!!", array[i]);
79
80     yield;
81
82     if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
83         return;
84
85     setTimeout(startIteration, 0);
86 }
87
88 </script>
89 </body>
90 </html>