Add performance tests for traversal of collections returned by getElementsByClassName...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 22:27:56 +0000 (22:27 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 22:27:56 +0000 (22:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148080

Reviewed by Antti Koivisto.

Add performance tests for traversal of *uncached* collections returned
by getElementsByClassName() / getElementsByTagName(). These methods
will soon be updated to return an HTMLCollection instead of a
NodeList and we need to make sure we don't regress performance in the
process.

* DOM/get-elements-by-class-name-traversal-uncached.html: Added.
* DOM/get-elements-by-tag-name-traversal-uncached.html: Added.

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

PerformanceTests/ChangeLog
PerformanceTests/DOM/get-elements-by-class-name-traversal-uncached.html [new file with mode: 0644]
PerformanceTests/DOM/get-elements-by-tag-name-traversal-uncached.html [new file with mode: 0644]

index 8238ca4..d0f6454 100644 (file)
@@ -1,3 +1,19 @@
+2015-08-17  Chris Dumez  <cdumez@apple.com>
+
+        Add performance tests for traversal of collections returned by getElementsByClassName() / getElementsByTagName()
+        https://bugs.webkit.org/show_bug.cgi?id=148080
+
+        Reviewed by Antti Koivisto.
+
+        Add performance tests for traversal of *uncached* collections returned
+        by getElementsByClassName() / getElementsByTagName(). These methods
+        will soon be updated to return an HTMLCollection instead of a
+        NodeList and we need to make sure we don't regress performance in the
+        process.
+
+        * DOM/get-elements-by-class-name-traversal-uncached.html: Added.
+        * DOM/get-elements-by-tag-name-traversal-uncached.html: Added.
+
 2015-08-14  Chris Dumez  <cdumez@apple.com>
 
         Add performance tests for NodeList and HTMLCollection traversal
diff --git a/PerformanceTests/DOM/get-elements-by-class-name-traversal-uncached.html b/PerformanceTests/DOM/get-elements-by-class-name-traversal-uncached.html
new file mode 100644 (file)
index 0000000..1f837e8
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/runner.js"></script>
+<script>
+function runTest() {
+    PerfTestRunner.measureRunsPerSecond({
+        description: "This benchmark covers 'getElementsByClassName'.",
+        run: function() {
+            var testDocument = document.getElementById("testFrame").contentDocument;
+            for (var i = 0; i < 10; i++) {
+                var elements = testDocument.getElementsByClassName("example");
+                // Do not access length so that we do not cache the elements.
+                var j = 0;
+                while (elements.item(j++)) { }
+            }
+        }
+    });
+}
+</script>
+</head>
+<body onload="runTest()">
+<iframe id="testFrame" src="../Parser/resources/html5.html" style="display:none" sandbox></iframe>
+</body>
+</html>
diff --git a/PerformanceTests/DOM/get-elements-by-tag-name-traversal-uncached.html b/PerformanceTests/DOM/get-elements-by-tag-name-traversal-uncached.html
new file mode 100644 (file)
index 0000000..fc3fb40
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../resources/runner.js"></script>
+<script>
+function runTest() {
+    PerfTestRunner.measureRunsPerSecond({
+        description: "This benchmark covers 'getElementsByTagName'.",
+        run: function() {
+            var testDocument = document.getElementById("testFrame").contentDocument;
+            for (var i = 0; i < 10; i++) {
+                var elements = testDocument.getElementsByTagName("p");
+                // Do not access length so that we do not cache the elements.
+                var j = 0;
+                while (elements.item(j++)) { }
+            }
+        }
+    });
+}
+</script>
+</head>
+<body onload="runTest()">
+<iframe id="testFrame" src="../Parser/resources/html5.html" style="display:none" sandbox></iframe>
+</body>
+</html>