Enable HAVE_AVFOUNDATION_VIDEO_OUTPUT on PLATFORM(IOSMAC)
[WebKit-https.git] / PerformanceTests / IndexedDB / large-string-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 = 10;
54 var array = new Array(numberOfInserts);
55 for (var i = 0; i < numberOfInserts; ++i)
56     array[i] = baseString + i;
57
58 function *runIteration()
59 {
60     var openRequest = indexedDB.open(databasePrefix + currentIteration);
61     openRequest.onupgradeneeded = function(event) {
62         db = event.target.result;
63         db.createObjectStore('arrays');
64     }
65     openRequest.onsuccess = nextStep;
66
67     yield;
68
69     var startTime = PerfTestRunner.now();
70
71     var objectStore = db.transaction('arrays', 'readwrite').objectStore('arrays');
72     objectStore.transaction.oncomplete = nextStep;
73
74     for (var i = 0; i < numberOfInserts; ++i)
75         objectStore.put("Some value!!!", array[i]);
76
77     yield;
78
79     if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
80         return;
81
82     setTimeout(startIteration, 0);
83 }
84
85 </script>
86 </body>
87 </html>