diff --git a/components/style/context.rs b/components/style/context.rs index 1eadf4cb845..4086483e10e 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -223,6 +223,12 @@ impl TraversalStatistics { self.is_parallel = Some(traversal.is_parallel()); self.traversal_time_ms = (time::precise_time_s() - start) * 1000.0; } + + /// Returns whether this traversal is 'large' in order to avoid console spam + /// from lots of tiny traversals. + pub fn is_large_traversal(&self) -> bool { + self.elements_traversed >= 50 + } } #[cfg(feature = "gecko")] diff --git a/components/style/parallel.rs b/components/style/parallel.rs index 18b15e12a3a..6495f41ee69 100644 --- a/components/style/parallel.rs +++ b/components/style/parallel.rs @@ -86,7 +86,9 @@ pub fn traverse_dom(traversal: &D, } }); aggregate.finish(traversal, start_time.unwrap()); - println!("{}", aggregate); + if aggregate.is_large_traversal() { + println!("{}", aggregate); + } } } diff --git a/components/style/sequential.rs b/components/style/sequential.rs index f0b10d34d2a..74c20d5bf01 100644 --- a/components/style/sequential.rs +++ b/components/style/sequential.rs @@ -64,6 +64,8 @@ pub fn traverse_dom(traversal: &D, if dump_stats { let tlsc = tlc.borrow_mut(); tlsc.statistics.finish(traversal, start_time.unwrap()); - println!("{}", tlsc.statistics); + if tlsc.statistics.is_large_traversal() { + println!("{}", tlsc.statistics); + } } }