Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: PerformanceTests/CSS/SelectorCountScaling.html

Issue 209153002: Add attribute selectors to the SelectorCountScaling performance test. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/runner.js"></script> 4 <script src="../resources/runner.js"></script>
5 <style> 5 <style>
6 .root .child {} 6 .root .child {}
7 </style> 7 </style>
8 </head> 8 </head>
9 <body> 9 <body>
10 <div id="root"></div> 10 <div id="root"></div>
11 <script> 11 <script>
12 function insertStyleSheet(css) 12 function insertStyleSheet(css)
13 { 13 {
14 var styleElement = document.createElement("style"); 14 var styleElement = document.createElement("style");
15 styleElement.textContent = css; 15 styleElement.textContent = css;
16 document.head.appendChild(styleElement); 16 document.head.appendChild(styleElement);
17 return styleElement; 17 return styleElement;
18 } 18 }
19 19
20 function cssStr(count) { 20 function cssStrWithClassSelectors(count) {
21 var selector = '.a' + count + ' .b' + count + ' { color: red } '; 21 var selector = '.a' + count + ' .b' + count + ' { color: red } ';
22 // Intentionally repeat the same classes many times, to test duplicate optim izations. 22 // Intentionally repeat the same classes many times, to test duplicate optim izations.
23 return selector + selector + selector + selector + selector + selector + sel ector; 23 return selector + selector + selector + selector + selector + selector + sel ector;
24 } 24 }
25 25
26 function cssStrWithAttributeSelectors(count) {
27 var selector = '[attrA' + count + '="1"]' + ' [attrB' + count + '="1"]' + ' { color: red } ';
28 // Intentionally repeat the same classes many times, to test duplicate optim izations.
29 return selector + selector + selector + selector + selector + selector + sel ector;
30 }
31
26 function runFunction() 32 function runFunction()
27 { 33 {
28 var numRules = 1000; 34 var numRules = 1000;
29 var arr = new Array(numRules); 35 var arr = new Array(numRules);
30 for (var i = 0 ; i < numRules; i++) { 36 for (var i = 0 ; i < numRules; i++) {
31 arr[i] = cssStr(i); 37 arr[i] = cssStrWithClassSelectors(i);
38 }
39 for (var i = 0 ; i < numRules; i++) {
40 arr[numRules + i] = cssStrWithAttributeSelectors(i);
32 } 41 }
33 var styleElement = insertStyleSheet(arr.join(' ')); 42 var styleElement = insertStyleSheet(arr.join(' '));
34 43
35 // Force style recalc. 44 // Force style recalc.
36 document.body.offsetTop; 45 document.body.offsetTop;
37 46
38 styleElement.parentNode.removeChild(styleElement); 47 styleElement.parentNode.removeChild(styleElement);
39 } 48 }
40 49
41 PerfTestRunner.measureRunsPerSecond({run: runFunction}); 50 PerfTestRunner.measureRunsPerSecond({run: runFunction});
42 51
43 </script> 52 </script>
44 </body> 53 </body>
45 </html> 54 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698