[Shadow] Performance tests of distribution for changing select attribute
authorshinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2012 11:26:33 +0000 (11:26 +0000)
committershinyak@chromium.org <shinyak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Nov 2012 11:26:33 +0000 (11:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103611

Reviewed by Hajime Morita.

We would like to measure ShadowDOM performance and compare it to the similar functional HTML without using ShadowDOM.
In this patch, we add a case when select attribute of HTMLContentElement is changed.

* ShadowDOM/ChangingSelect.html: Added.
* ShadowDOM/ChangingSelectWithoutShadow.html: Added.
* Skipped:

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

PerformanceTests/ChangeLog
PerformanceTests/ShadowDOM/ChangingSelect.html [new file with mode: 0644]
PerformanceTests/ShadowDOM/ChangingSelectWithoutShadow.html [new file with mode: 0644]
PerformanceTests/Skipped

index 3bc5a1e..fbb36e5 100644 (file)
@@ -1,3 +1,17 @@
+2012-11-29  Shinya Kawanaka  <shinyak@chromium.org>
+
+        [Shadow] Performance tests of distribution for changing select attribute
+        https://bugs.webkit.org/show_bug.cgi?id=103611
+
+        Reviewed by Hajime Morita.
+
+        We would like to measure ShadowDOM performance and compare it to the similar functional HTML without using ShadowDOM.
+        In this patch, we add a case when select attribute of HTMLContentElement is changed.
+
+        * ShadowDOM/ChangingSelect.html: Added.
+        * ShadowDOM/ChangingSelectWithoutShadow.html: Added.
+        * Skipped:
+
 2012-11-19  Shinya Kawanaka  <shinyak@chromium.org>
 
         Changing id, className, or attribute should invalidate distribution
diff --git a/PerformanceTests/ShadowDOM/ChangingSelect.html b/PerformanceTests/ShadowDOM/ChangingSelect.html
new file mode 100644 (file)
index 0000000..246d4df
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script type="text/javascript" src="../resources/runner.js"></script>
+</head>
+<body>
+
+<div id="wrapper">
+    <div id="host"></div>
+</div>
+
+<script>
+var numDivsInHost = 100;
+var typeNames = ['A', 'B', 'C'];
+var array = new Array(numDivsInHost);
+
+function setup()
+{
+    var nDivs = numDivsInHost;
+
+    window.shadowRoot = new WebKitShadowRoot(host);
+    shadowRoot.innerHTML = '<h2>Selected</h2><div id="selected"><content select=".selected"></content></div><h2>NonSelected</h2><div id="nonselected"><content></content></div>';
+
+    for (var i = 0; i < nDivs; ++i) {
+        var div = document.createElement('div');
+        div.appendChild(document.createTextNode('div' + i));
+        div.className = typeNames[i % typeNames.length];
+        host.appendChild(div);
+        array[i] = div;
+    }
+}
+
+function run()
+{
+    var nDivs = numDivsInHost;
+    var array = window.array;
+
+    var selected = shadowRoot.getElementById('selected');
+    var nonSelected = shadowRoot.getElementById('nonselected');
+    var contentSelected = selected.querySelector('content');
+
+    for (var i = 0; i < 100; ++i) {
+        for (var j = 0; j < typeNames.length; ++j) {
+            contentSelected.select = '.' + typeNames[j];
+
+            selected.offsetLeft;
+            nonSelected.offsetLeft;
+        }
+    }
+}
+
+function done()
+{
+    wrapper.innerHTML = '';
+}
+
+
+setup();
+
+PerfTestRunner.measureTime({
+    description: "Measure distribution and layout performance when select attribute is changed",
+    run: run,
+    done: done
+});
+</script>
+</body>
+</html>
diff --git a/PerformanceTests/ShadowDOM/ChangingSelectWithoutShadow.html b/PerformanceTests/ShadowDOM/ChangingSelectWithoutShadow.html
new file mode 100644 (file)
index 0000000..3afc325
--- /dev/null
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script type="text/javascript" src="../resources/runner.js"></script>
+</head>
+<body>
+
+<div id="wrapper">
+    <h2>Selected</h2>
+    <div id="selected"></div>
+    <h2>NonSelected</h2>
+    <div id="nonselected"></div>
+</div>
+
+<script>
+var numDivsInHost = 100;
+var typeNames = ['A', 'B', 'C'];
+var array = new Array(numDivsInHost);
+
+function setup()
+{
+    var nDivs = numDivsInHost;
+    var nonSelected = document.getElementById('nonselected');
+
+    for (var i = 0; i < nDivs; ++i) {
+        var div = document.createElement('div');
+        div.appendChild(document.createTextNode('div' + i));
+        div.className = typeNames[i % typeNames.length]
+        array[i] = div;
+        nonSelected.appendChild(div);
+    }
+}
+
+function run()
+{
+    var nDivs = numDivsInHost;
+    var array = window.array;
+
+    var selected = document.getElementById('selected');
+    var nonSelected = document.getElementById('nonselected');
+
+    for (var i = 0; i < 100; ++i) {
+        for (var j = 0; j < typeNames.length; ++j) {
+            for (var k = 0; k < nDivs; ++k) {
+                if (array[k].className == typeNames[j])
+                    selected.appendChild(array[k]);
+                else
+                    nonSelected.appendChild(array[k]);
+            }
+            selected.offsetLeft;
+            nonSelected.offsetLeft;
+        }
+    }
+}
+
+function done()
+{
+    wrapper.innerHTML = '';
+}
+
+setup();
+
+PerfTestRunner.measureTime({
+    description: "Measure distribution and layout performance when we do the almost same thing as select attribute of content element is changed using JavaScript",
+    run: run,
+    done: done
+});
+</script>
+</body>
+</html>
index 3270601..509234a 100644 (file)
@@ -60,3 +60,5 @@ inspector
 # Bug 100262 - REGRESSION(r131982): this test is crashing
 SVG/SvgNestedUse.html
 
+# Bug 102646 - ShadowDOM is not enabled in some ports.
+ShadowDOM