layout: Profile the CSS cascade as well as selector matching.

It's slow.
This commit is contained in:
Patrick Walton 2014-01-25 18:13:59 -08:00
parent edda06115a
commit 55ccfae1e8
2 changed files with 7 additions and 3 deletions

View file

@ -522,6 +522,8 @@ impl LayoutTask {
_ => { _ => {
profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone(), || { profile(time::LayoutSelectorMatchCategory, self.profiler_chan.clone(), || {
node.match_subtree(self.stylist.clone()); node.match_subtree(self.stylist.clone());
});
profile(time::LayoutSelectorCascadeCategory, self.profiler_chan.clone(), || {
node.cascade_subtree(None); node.cascade_subtree(None);
}); });
} }

View file

@ -52,6 +52,7 @@ pub enum ProfilerCategory {
LayoutPerformCategory, LayoutPerformCategory,
LayoutAuxInitCategory, LayoutAuxInitCategory,
LayoutSelectorMatchCategory, LayoutSelectorMatchCategory,
LayoutSelectorCascadeCategory,
LayoutTreeBuilderCategory, LayoutTreeBuilderCategory,
LayoutMainCategory, LayoutMainCategory,
LayoutParallelWarmupCategory, LayoutParallelWarmupCategory,
@ -79,6 +80,7 @@ impl ProfilerCategory {
buckets.insert(LayoutPerformCategory, ~[]); buckets.insert(LayoutPerformCategory, ~[]);
buckets.insert(LayoutAuxInitCategory, ~[]); buckets.insert(LayoutAuxInitCategory, ~[]);
buckets.insert(LayoutSelectorMatchCategory, ~[]); buckets.insert(LayoutSelectorMatchCategory, ~[]);
buckets.insert(LayoutSelectorCascadeCategory, ~[]);
buckets.insert(LayoutTreeBuilderCategory, ~[]); buckets.insert(LayoutTreeBuilderCategory, ~[]);
buckets.insert(LayoutMainCategory, ~[]); buckets.insert(LayoutMainCategory, ~[]);
buckets.insert(LayoutParallelWarmupCategory, ~[]); buckets.insert(LayoutParallelWarmupCategory, ~[]);
@ -96,9 +98,9 @@ impl ProfilerCategory {
// and should be printed to indicate this // and should be printed to indicate this
pub fn format(self) -> ~str { pub fn format(self) -> ~str {
let padding = match self { let padding = match self {
LayoutAuxInitCategory | LayoutSelectorMatchCategory | LayoutTreeBuilderCategory | LayoutAuxInitCategory | LayoutSelectorMatchCategory | LayoutSelectorCascadeCategory |
LayoutMainCategory | LayoutDispListBuildCategory | LayoutShapingCategory | LayoutTreeBuilderCategory | LayoutMainCategory | LayoutDispListBuildCategory |
LayoutParallelWarmupCategory => " - ", LayoutShapingCategory | LayoutParallelWarmupCategory => " - ",
_ => "" _ => ""
}; };
format!("{:s}{:?}", padding, self) format!("{:s}{:?}", padding, self)