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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h

Issue 2533093002: [LazyParseCSS] Add histogram for rule usage % (Closed)
Patch Set: timloh review + add test Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h
diff --git a/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h b/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h
index 3234141f9e8102319f61a3445b02234ad56bf2a3..e81fa877855e604aea7953fe77092618c5e1bad4 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h
+++ b/third_party/WebKit/Source/core/css/parser/CSSLazyParsingState.h
@@ -13,6 +13,7 @@
namespace blink {
+class CSSLazyPropertyParserImpl;
class CSSParserTokenRange;
// This class helps lazy parsing by retaining necessary state. It should not
@@ -26,14 +27,32 @@ class CSSLazyParsingState
const String& sheetText,
StyleSheetContents*);
+ // Helper method used to bump m_totalStyleRules.
+ CSSLazyPropertyParserImpl* createLazyParser(const CSSParserTokenRange& block);
+
const CSSParserContext& context();
+ void countRuleParsed();
+
bool shouldLazilyParseProperties(const CSSSelectorList&,
- const CSSParserTokenRange& block);
+ const CSSParserTokenRange& block) const;
DEFINE_INLINE_TRACE() { visitor->trace(m_owningContents); }
+ // Exposed for tests.
Ilya Sherman 2016/12/01 00:48:21 Please document that this enum is used to back an
Charlie Harrison 2016/12/01 02:43:51 Done.
+ enum CSSRuleUsage {
+ UsageGe0 = 0,
+ UsageGt10 = 1,
+ UsageGt25 = 2,
+ UsageGt50 = 3,
+ UsageGt75 = 4,
+ UsageGt90 = 5,
+ UsageAll = 6
+ };
+
private:
+ void recordUsageMetrics();
+
CSSParserContext m_context;
Vector<String> m_escapedStrings;
// Also referenced on the css resource.
@@ -42,6 +61,14 @@ class CSSLazyParsingState
// Weak to ensure lazy state will never cause the contents to live longer than
// it should (we DCHECK this fact).
WeakMember<StyleSheetContents> m_owningContents;
+
+ // Used for calculating the % of rules that ended up being parsed.
+ int m_parsedStyleRules;
+ int m_totalStyleRules;
+
+ int m_styleRulesNeededForNextMilestone;
+
+ int m_usage;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698