Add a PerfTest targeting IDBObjectStore.get().
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 20:41:42 +0000 (20:41 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 20:41:42 +0000 (20:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165816

Reviewed by Alex Christensen.

* IndexedDB/objectstore-get.html: Added.

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

PerformanceTests/ChangeLog
PerformanceTests/IndexedDB/objectstore-get.html [new file with mode: 0644]

index eef1873..bcc6c7c 100644 (file)
@@ -1,5 +1,14 @@
 2016-12-13  Brady Eidson  <beidson@apple.com>
 
+        Add a PerfTest targeting IDBObjectStore.get().
+        https://bugs.webkit.org/show_bug.cgi?id=165816
+
+        Reviewed by Alex Christensen.
+
+        * IndexedDB/objectstore-get.html: Added.
+
+2016-12-13  Brady Eidson  <beidson@apple.com>
+
         Add a PerfTest targeting IDBIndex.get().
         https://bugs.webkit.org/show_bug.cgi?id=165803
 
diff --git a/PerformanceTests/IndexedDB/objectstore-get.html b/PerformanceTests/IndexedDB/objectstore-get.html
new file mode 100644 (file)
index 0000000..6a4c8ac
--- /dev/null
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/runner.js"></script>
+<script>
+
+// Delete database(s) for the test ahead of time.
+var databaseName = "objectstore-get-DB";
+indexedDB.deleteDatabase(databaseName).onsuccess = function() {
+    startIteration();
+}
+
+var testGenerator = null;
+var db = null;
+var transaction = null;
+
+PerfTestRunner.prepareToMeasureValuesAsync({
+    customIterationCount: 20,
+    unit: 'ms',
+    done: function () {
+        transaction = null;
+        db = null;
+        testGenerator = null;
+        PerfTestRunner.gc();
+    }
+});
+
+function startIteration()
+{
+    testGenerator = runIteration();
+    nextStep();
+}
+
+function nextStep()
+{
+    testGenerator.next();
+}
+
+var numberOfEntries = 5000;
+
+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 < numberOfEntries; ++i)
+           objectStore.put("index" + i, i);
+    }
+    openRequest.onsuccess = nextStep;
+
+    yield;
+
+    var startTime = PerfTestRunner.now();
+
+    var objectStore = db.transaction('store').objectStore('store');
+    var completedGets = 0;
+    for (var i = 0; i < numberOfEntries; ++i)
+    {
+        
+        objectStore.get(i).onsuccess = (function (j) {
+            return function(event) {
+                if (event.target.result != ("index" + j))
+                    alert("Expected 'index" + j + "', got '" + event.target.result + "'");
+
+                if (++completedGets == numberOfEntries)
+                    nextStep();
+            }
+        })(i);
+    }
+
+    yield;
+
+    if (!PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime))
+        return;
+
+    setTimeout(startIteration, 0);
+}
+</script>
+</body>
+</html>