| <!DOCTYPE html> |
| <html> |
| <body> |
| <script src="../resources/runner.js"></script> |
| <script> |
| |
| var iterationCount = 20; |
| var numberDeleted = 0; |
| |
| var quota = 500 * 1024 * 1024; //500MB |
| if (window.testRunner) |
| testRunner.setIDBPerOriginQuota(quota); |
| |
| // Delete all databases for the test ahead of time. |
| var databasePrefix = "large-string-keys-DB-"; |
| for (var i = 0; i < iterationCount + 1; ++i) { |
| indexedDB.deleteDatabase(databasePrefix + i).onsuccess = function() { |
| if (++numberDeleted == iterationCount) |
| startIteration(); |
| } |
| } |
| |
| var testGenerator = null; |
| var db = null; |
| var currentIteration = 0; |
| |
| PerfTestRunner.prepareToMeasureValuesAsync({ |
| customIterationCount: iterationCount, |
| unit: 'ms', |
| done: function () { |
| db = null; |
| testGenerator = null; |
| PerfTestRunner.gc(); |
| ++currentIteration; |
| } |
| }); |
| |
| function startIteration() |
| { |
| testGenerator = runIteration(); |
| nextStep(); |
| } |
| |
| function nextStep() |
| { |
| testGenerator.next(); |
| } |
| |
| var baseString; |
| for (var i = 0; i < 100000; ++i) |
| baseString += "abcdefghijklmnopqrstuvwxyz"; |
| |
| var numberOfInserts = 50; |
| var array = new Array(numberOfInserts); |
| for (var i = 0; i < numberOfInserts; ++i) { |
| array[i] = new ArrayBuffer(2097152); |
| var view = new Int32Array(array[i]); |
| view[view.length - 1] = i; |
| } |
| |
| function *runIteration() |
| { |
| var openRequest = indexedDB.open(databasePrefix + currentIteration); |
| openRequest.onupgradeneeded = function(event) { |
| db = event.target.result; |
| db.createObjectStore('arrays'); |
| } |
| openRequest.onsuccess = nextStep; |
| |
| yield; |
| |
| var startTime = PerfTestRunner.now(); |
| |
| var objectStore = db.transaction('arrays', 'readwrite').objectStore('arrays'); |
| objectStore.transaction.oncomplete = nextStep; |
| |
| for (var i = 0; i < numberOfInserts; ++i) |
| objectStore.put("Some value!!!", array[i]); |
| |
| yield; |
| |
| if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime)) |
| return; |
| |
| setTimeout(startIteration, 0); |
| } |
| |
| </script> |
| </body> |
| </html> |