Add IDB perf tests stressing key size.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 00:50:17 +0000 (00:50 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 00:50:17 +0000 (00:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165567

Reviewed by Alex Christensen.

* IndexedDB/large-array-keys.html: Added.
* IndexedDB/large-binary-keys.html: Added.
* IndexedDB/large-string-keys.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209499 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/IndexedDB/large-array-keys.html [new file with mode: 0644]
PerformanceTests/IndexedDB/large-binary-keys.html [new file with mode: 0644]
PerformanceTests/IndexedDB/large-string-keys.html [new file with mode: 0644]

index 5d1a885..1b40fd6 100644 (file)
@@ -1,3 +1,14 @@
+2016-12-07  Brady Eidson  <beidson@apple.com>
+
+        Add IDB perf tests stressing key size.
+        https://bugs.webkit.org/show_bug.cgi?id=165567
+
+        Reviewed by Alex Christensen.
+
+        * IndexedDB/large-array-keys.html: Added.
+        * IndexedDB/large-binary-keys.html: Added.
+        * IndexedDB/large-string-keys.html: Added.
+
 2016-12-05  Brady Eidson  <beidson@apple.com>
 
         Add an IndexedDB perf test to PerformanceTests.
diff --git a/PerformanceTests/IndexedDB/large-array-keys.html b/PerformanceTests/IndexedDB/large-array-keys.html
new file mode 100644 (file)
index 0000000..b50e93c
--- /dev/null
@@ -0,0 +1,90 @@
+<!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>
diff --git a/PerformanceTests/IndexedDB/large-binary-keys.html b/PerformanceTests/IndexedDB/large-binary-keys.html
new file mode 100644 (file)
index 0000000..72a71cf
--- /dev/null
@@ -0,0 +1,86 @@
+<!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-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>
diff --git a/PerformanceTests/IndexedDB/large-string-keys.html b/PerformanceTests/IndexedDB/large-string-keys.html
new file mode 100644 (file)
index 0000000..916d90a
--- /dev/null
@@ -0,0 +1,83 @@
+<!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-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 = 10;
+var array = new Array(numberOfInserts);
+for (var i = 0; i < numberOfInserts; ++i)
+    array[i] = baseString + 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>