blob: b50e93cd9a8f90f2024cbcc64f2a6259455f7a43 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var iterationCount = 20;
var numberDeleted = 0;
// Delete all databases for the test ahead of time.
var databasePrefix = "large-array-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();
}
function createSubArray(count)
{
var array = new Array(count);
for (var i = 0; i < count; ++i) {
array[i] = createSubArray(count - 1);
}
return array;
}
var numberOfSubarrays = 6;
var array = createSubArray(numberOfSubarrays);
array.push("variant");
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;
var numberOfInserts = 100;
for (var i = 0; i < numberOfInserts; ++i) {
array[numberOfSubarrays] = i;
objectStore.put("Some value!!!", array);
}
yield;
if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
return;
setTimeout(startIteration, 0);
}
</script>
</body>
</html>