haikuwebkit/PerformanceTests/CSS/PseudoClassSelectors.html

44 lines
1.0 KiB
HTML
Raw Permalink Normal View History

[Refactoring] Introduce a traversal strategy in SelectorChecker https://bugs.webkit.org/show_bug.cgi?id=97298 Reviewed by Antti Koivisto. PerformanceTests: Introduces querySelector() performance tests to check SelectorChecker performance. * CSS/PseudoClassSelectors.html: Added. Source/WebCore: We extract DOM traversal code from SelectorChecker so that we can use another traversal strategy. Another traversal strategy will be introduced in Bug 96990. Since this code path is very hot, we were very careful not to regress performance. We will use template specialization to change the traversal implementation. We confirmed that this patch does not regress SelectorCheckerPerformance. I have checked the performance of the added test in my Linux Box using run-perf-tests. The performance of the added test before using this patch was: RESULT CSS: PseudoClassSelectors= 3399.68308031 runs/s median= 3404.48685564 runs/s, stdev= 37.3480114449 runs/s, min= 3272.64871114 runs/s, max= 3438.72385184 runs/s When we used this patch, the performance was: RESULT CSS: PseudoClassSelectors= 3367.74473886 runs/s median= 3367.12072755 runs/s, stdev= 14.1464547639 runs/s, min= 3348.55881171 runs/s, max= 3395.98212857 runs/s Test: PerformanceTests/CSS/PseudoClass-Selectors.html * css/SelectorChecker.cpp: (WebCore): (WebCore::SelectorChecker::checkSelector): Make this a template method to accept another Context type. Another Context type will be introduced in coming patch. (WebCore::SelectorChecker::checkOneSelector): (WebCore::SelectorChecker::DOMTraversalStrategy::isFirstChild): (WebCore::SelectorChecker::DOMTraversalStrategy::isLastChild): (WebCore::SelectorChecker::DOMTraversalStrategy::isFirstOfType): (WebCore::SelectorChecker::DOMTraversalStrategy::isLastOfType): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsBefore): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeBefore): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsAfter): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeAfter): * css/SelectorChecker.h: (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext): (SelectorCheckingContext): (SelectorChecker): (DOMTraversalStrategy): Extracted the DOM traversal code from SelectorChecker. Another traversal code will be introduced the coming patch. Canonical link: https://commits.webkit.org/116453@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-10-05 04:47:21 +00:00
<!DOCTYPE html>
<html>
<body>
<div id="test-target">
<div>
<div></div>
<div>
<p></p>
<p></p>
<p></p>
</div>
<div></div>
</div>
<div>
<div>
<p></p>
</div>
</div>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
<script src="../resources/runner.js"></script>
<script>
Rename PerfTestRunner.runPerSecond to PerfTestRunner.measureRunsPerSecond for consistency https://bugs.webkit.org/show_bug.cgi?id=99642 Reviewed by Dirk Pranke. Renamed the method. * Bindings/append-child.html: * Bindings/create-element.html: * Bindings/event-target-wrapper.html: * Bindings/first-child.html: * Bindings/get-attribute.html: * Bindings/get-element-by-id.html: * Bindings/get-elements-by-tag-name.html: * Bindings/id-getter.html: * Bindings/id-setter.html: * Bindings/insert-before.html: * Bindings/node-list-access.html: * Bindings/scroll-top.html: * Bindings/set-attribute.html: * Bindings/typed-array-construct-from-array.html: * Bindings/typed-array-construct-from-same-type.html: * Bindings/typed-array-construct-from-typed.html: * Bindings/typed-array-set-from-typed.html: * Bindings/undefined-first-child.html: * Bindings/undefined-get-element-by-id.html: * Bindings/undefined-id-getter.html: * CSS/CSSPropertySetterGetter.html: * CSS/CSSPropertyUpdateValue.html: * CSS/PseudoClassSelectors.html: * DOM/textarea-dom.html: * DOM/textarea-edit.html: * Interactive/resources/window-resize.js: * Layout/flexbox-column-nowrap.html: * Layout/flexbox-column-wrap.html: * Layout/flexbox-row-nowrap.html: * Layout/flexbox-row-wrap.html: * Layout/line-layout.html: * Parser/css-parser-yui.html: * Parser/innerHTML-setter.html: * Parser/query-selector-deep.html: * Parser/query-selector-first.html: * Parser/query-selector-last.html: * Parser/simple-url.html: * Parser/textarea-parsing.html: * Parser/tiny-innerHTML.html: * Parser/url-parser.html: * Parser/xml-parser.html: * SVG/SvgNestedUse.html: * resources/runner.js: Canonical link: https://commits.webkit.org/117606@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@131651 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-10-17 22:06:52 +00:00
PerfTestRunner.measureRunsPerSecond({
[Refactoring] Introduce a traversal strategy in SelectorChecker https://bugs.webkit.org/show_bug.cgi?id=97298 Reviewed by Antti Koivisto. PerformanceTests: Introduces querySelector() performance tests to check SelectorChecker performance. * CSS/PseudoClassSelectors.html: Added. Source/WebCore: We extract DOM traversal code from SelectorChecker so that we can use another traversal strategy. Another traversal strategy will be introduced in Bug 96990. Since this code path is very hot, we were very careful not to regress performance. We will use template specialization to change the traversal implementation. We confirmed that this patch does not regress SelectorCheckerPerformance. I have checked the performance of the added test in my Linux Box using run-perf-tests. The performance of the added test before using this patch was: RESULT CSS: PseudoClassSelectors= 3399.68308031 runs/s median= 3404.48685564 runs/s, stdev= 37.3480114449 runs/s, min= 3272.64871114 runs/s, max= 3438.72385184 runs/s When we used this patch, the performance was: RESULT CSS: PseudoClassSelectors= 3367.74473886 runs/s median= 3367.12072755 runs/s, stdev= 14.1464547639 runs/s, min= 3348.55881171 runs/s, max= 3395.98212857 runs/s Test: PerformanceTests/CSS/PseudoClass-Selectors.html * css/SelectorChecker.cpp: (WebCore): (WebCore::SelectorChecker::checkSelector): Make this a template method to accept another Context type. Another Context type will be introduced in coming patch. (WebCore::SelectorChecker::checkOneSelector): (WebCore::SelectorChecker::DOMTraversalStrategy::isFirstChild): (WebCore::SelectorChecker::DOMTraversalStrategy::isLastChild): (WebCore::SelectorChecker::DOMTraversalStrategy::isFirstOfType): (WebCore::SelectorChecker::DOMTraversalStrategy::isLastOfType): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsBefore): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeBefore): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsAfter): (WebCore::SelectorChecker::DOMTraversalStrategy::countElementsOfTypeAfter): * css/SelectorChecker.h: (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext): (SelectorCheckingContext): (SelectorChecker): (DOMTraversalStrategy): Extracted the DOM traversal code from SelectorChecker. Another traversal code will be introduced the coming patch. Canonical link: https://commits.webkit.org/116453@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-10-05 04:47:21 +00:00
description: "This benchmark tests CSS Selector performance with querySelector().",
run: function() {
for (var i = 0; i < 100; i++) {
document.querySelector("p:first-child");
document.querySelector("p:last-child");
document.querySelector("p:first-of-type");
document.querySelector("p:last-of-type");
document.querySelector("p:nth-child(4n+3)");
document.querySelector("p:nth-last-child(4n+3)");
document.querySelector("p:nth-of-type(4n+3)");
document.querySelector("p:nth-last-of-type(4n+3)");
}
}
});
</script>
</body>
</html>