More IndexedDB perf tests.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 00:12:55 +0000 (00:12 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 00:12:55 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165634

Reviewed by Sam Weinig.

* IndexedDB/index-multientry.html:
* IndexedDB/large-number-of-inserts-responsiveness.html: Added.
* IndexedDB/large-number-of-inserts.html: Added.
* IndexedDB/objectstore-cursor.html: Added. Runtime cut in 1/4th compared to r209672.

* resources/runner.js:

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

PerformanceTests/ChangeLog
PerformanceTests/IndexedDB/index-multientry.html
PerformanceTests/IndexedDB/large-number-of-inserts-responsiveness.html [new file with mode: 0644]
PerformanceTests/IndexedDB/large-number-of-inserts.html [new file with mode: 0644]
PerformanceTests/IndexedDB/objectstore-cursor.html [new file with mode: 0644]
PerformanceTests/resources/runner.js

index 85d6197..4fb6db0 100644 (file)
@@ -1,3 +1,17 @@
+2016-12-12  Brady Eidson  <beidson@apple.com>
+
+        More IndexedDB perf tests.
+        https://bugs.webkit.org/show_bug.cgi?id=165634
+
+        Reviewed by Sam Weinig.
+
+        * IndexedDB/index-multientry.html:
+        * IndexedDB/large-number-of-inserts-responsiveness.html: Added.
+        * IndexedDB/large-number-of-inserts.html: Added.
+        * IndexedDB/objectstore-cursor.html: Added. Runtime cut in 1/4th compared to r209672.
+
+        * resources/runner.js:
+
 2016-12-12  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r209672.
index 5b86b02..aa4f2ec 100644 (file)
@@ -4,12 +4,14 @@
 <script src="../resources/runner.js"></script>
 <script>
 
-var iterationCount = 11;
+var iterationCount = 20;
 var numberDeleted = 0;
 
 // Delete all databases for the test ahead of time.
-for (var i = 0; i < iterationCount; ++i) {
-    indexedDB.deleteDatabase("index-multientry-DB-" + i).onsuccess = function() {
+var databaseNamePrefix = "index-multientry-DB-";
+for (var i = 0; i < iterationCount + 1; ++i) {
+    req = indexedDB.deleteDatabase(databaseNamePrefix + i);
+    req.onsuccess = function() {
         if (++numberDeleted == iterationCount)
             startIteration();
     }
@@ -44,14 +46,14 @@ function nextStep()
 }
 
 var object = { test: 'yo', indexKeys: [] };
-for (var i = 0; i < 1000; i++)
+for (var i = 0; i < 5000; i++)
     object.indexKeys.push('index_no_' + i);
 
 function *runIteration()
 {
     var startTime = PerfTestRunner.now();
 
-    var openRequest = indexedDB.open("index-multientry-DB-" + currentIteration);
+    var openRequest = indexedDB.open(databaseNamePrefix + currentIteration);
     openRequest.onupgradeneeded = function(event) {
         db = event.target.result;
         db.createObjectStore('store').createIndex('index', 'indexKeys', { multiEntry: true });
diff --git a/PerformanceTests/IndexedDB/large-number-of-inserts-responsiveness.html b/PerformanceTests/IndexedDB/large-number-of-inserts-responsiveness.html
new file mode 100644 (file)
index 0000000..69ff6b5
--- /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-number-of-inserts-responsiveness-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;
+        largestDelay = 0;
+        testGenerator = null;
+        PerfTestRunner.gc();
+        ++currentIteration;
+    }
+});
+
+function startIteration()
+{
+    testGenerator = runIteration();
+    nextStep();
+}
+
+function nextStep()
+{
+    testGenerator.next();
+}
+
+var numberOfObjects = 50000;
+var objectsToInsert = new Array(numberOfObjects);
+for (var i = 0; i < numberOfObjects; ++i) {
+    objectsToInsert[i] = { data: Math.random() };
+    objectsToInsert[i].id = 'object_' + i;
+}
+
+function *runIteration()
+{
+    var openRequest = indexedDB.open(databasePrefix + currentIteration);
+    openRequest.onupgradeneeded = function(event) {
+        db = event.target.result;
+        db.createObjectStore('objects', {keyPath: 'id'});
+    }
+    openRequest.onsuccess = nextStep;
+
+    yield;
+
+    var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
+    objectStore.transaction.oncomplete = nextStep;
+    for (var i = 0; i < numberOfObjects; ++i)
+        objectStore.put(objectsToInsert[i]);
+
+    PerfTestRunner.startCheckingResponsiveness();
+
+    yield;
+
+    PerfTestRunner.stopCheckingResponsiveness();
+    
+    if (!PerfTestRunner.measureValueAsync(PerfTestRunner.longestResponsivenessDelay()))
+        return;
+
+    setTimeout(startIteration, 0);
+}
+
+</script>
+</body>
+</html>
diff --git a/PerformanceTests/IndexedDB/large-number-of-inserts.html b/PerformanceTests/IndexedDB/large-number-of-inserts.html
new file mode 100644 (file)
index 0000000..7add728
--- /dev/null
@@ -0,0 +1,80 @@
+<!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-number-of-inserts-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 numberOfObjects = 100000;
+var objectsToInsert = new Array(numberOfObjects);
+for (var i = 0; i < numberOfObjects; ++i) {
+    objectsToInsert[i] = { data: Math.random() };
+    objectsToInsert[i].id = 'object_' + i;
+}
+
+function *runIteration()
+{
+    var openRequest = indexedDB.open(databasePrefix + currentIteration);
+    openRequest.onupgradeneeded = function(event) {
+        db = event.target.result;
+        db.createObjectStore('objects', {keyPath: 'id'});
+    }
+    openRequest.onsuccess = nextStep;
+
+    yield;
+
+    var startTime = PerfTestRunner.now();
+
+    var objectStore = db.transaction('objects', 'readwrite').objectStore('objects');
+    objectStore.transaction.oncomplete = nextStep;
+    for (var i = 0; i < numberOfObjects; ++i)
+        objectStore.put(objectsToInsert[i]);
+
+    yield;
+
+    if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
+        return;
+
+    setTimeout(startIteration, 0);
+}
+
+</script>
+</body>
+</html>
diff --git a/PerformanceTests/IndexedDB/objectstore-cursor.html b/PerformanceTests/IndexedDB/objectstore-cursor.html
new file mode 100644 (file)
index 0000000..db5db93
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/runner.js"></script>
+<script>
+
+var iterationCount = 10;
+var numberDeleted = 0;
+// Delete all databases for the test ahead of time.
+var databaseName = "objectstore-cursor-DB";
+indexedDB.deleteDatabase(databaseName).onsuccess = function() {
+    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 *runIteration()
+{
+    var openRequest = indexedDB.open(databaseName);
+    openRequest.onupgradeneeded = function(event) {
+        db = event.target.result;
+        var objectStore = db.createObjectStore('store');
+        for (var i = 0; i < 25000; ++i) {
+            var suffix = ("0000000" + i).slice(-7);
+            objectStore.put("bar_value_" + suffix, "foo_key_" + suffix);
+        }
+    }
+    openRequest.onsuccess = nextStep;
+
+    yield;
+
+    var startTime = PerfTestRunner.now();
+    var cursorRequest = db.transaction('store').objectStore('store').openCursor();
+    var cursorIteration = 0;
+    cursorRequest.onsuccess = function(event) {
+        var cursor = event.target.result;
+        if (cursor) {
+            var suffix = ("0000000" + cursorIteration).slice(-7);
+            if (cursor.key != "foo_key_" + suffix)
+                alert("Incorrect value retrieved: " + cursor.key);
+            if (cursor.value != "bar_value_" + suffix)
+                alert("Incorrect value retrieved: " + cursor.key);
+            ++cursorIteration;
+            cursor.continue();
+        } else
+            nextStep();
+    };
+
+    yield;
+
+    if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
+        return;
+
+    setTimeout(startIteration, 0);
+}
+</script>
+</body>
+</html>
index eb01515..af2e03a 100755 (executable)
@@ -15,6 +15,9 @@ if (window.testRunner) {
     var jsHeapResults;
     var mallocHeapResults;
     var iterationCount = undefined;
+    var lastResponsivenessTimestamp = 0;
+    var _longestResponsivenessDelay = 0;
+    var continueCheckingResponsiveness = false;
 
     var PerfTestRunner = {};
 
@@ -323,6 +326,32 @@ if (window.testRunner) {
         return PerfTestRunner.now() - startTime;
     }
 
+    PerfTestRunner.startCheckingResponsiveness = function() {
+        lastResponsivenessTimestamp = PerfTestRunner.now();
+        _longestResponsivenessDelay = 0;
+        continueCheckingResponsiveness = true;
+
+        var timeoutFunction = function() {
+            var now = PerfTestRunner.now();
+            var delta = now - lastResponsivenessTimestamp;
+            if (delta > _longestResponsivenessDelay)
+                _longestResponsivenessDelay = delta;    
+
+            lastResponsivenessTimestamp = now;
+            if (continueCheckingResponsiveness)
+                setTimeout(timeoutFunction, 0);
+        }
+        
+        timeoutFunction();
+    }
+
+    PerfTestRunner.stopCheckingResponsiveness = function() {
+        continueCheckingResponsiveness = false;
+    }
+
+    PerfTestRunner.longestResponsivenessDelay = function() {
+        return _longestResponsivenessDelay;
+    }
 
     PerfTestRunner.measurePageLoadTime = function(test) {
         test.run = function() {