OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/layout/LayoutAnalyzer.h" | 6 #include "core/layout/LayoutAnalyzer.h" |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/layout/LayoutObject.h" | 9 #include "core/layout/LayoutObject.h" |
10 #include "core/layout/LayoutText.h" | 10 #include "core/layout/LayoutText.h" |
11 #include "platform/TracedValue.h" | 11 #include "platform/TracedValue.h" |
12 #include "public/platform/Platform.h" | |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 | 14 |
16 LayoutAnalyzer::Scope::Scope(const LayoutObject& o) | 15 LayoutAnalyzer::Scope::Scope(const LayoutObject& o) |
17 : m_layoutObject(o) | 16 : m_layoutObject(o) |
18 , m_analyzer(o.frameView()->layoutAnalyzer()) | 17 , m_analyzer(o.frameView()->layoutAnalyzer()) |
19 { | 18 { |
20 if (m_analyzer) | 19 if (m_analyzer) |
21 m_analyzer->push(o); | 20 m_analyzer->push(o); |
22 } | 21 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // stack recursion depth, not layout tree depth or DOM tree depth. | 73 // stack recursion depth, not layout tree depth or DOM tree depth. |
75 m_counters[LayoutAnalyzerStackMaximumDepth] = max(m_counters[LayoutAnalyzerS
tackMaximumDepth], m_depth); | 74 m_counters[LayoutAnalyzerStackMaximumDepth] = max(m_counters[LayoutAnalyzerS
tackMaximumDepth], m_depth); |
76 } | 75 } |
77 | 76 |
78 void LayoutAnalyzer::pop(const LayoutObject& o) | 77 void LayoutAnalyzer::pop(const LayoutObject& o) |
79 { | 78 { |
80 ASSERT(m_depth > 0); | 79 ASSERT(m_depth > 0); |
81 --m_depth; | 80 --m_depth; |
82 } | 81 } |
83 | 82 |
84 void LayoutAnalyzer::recordCounters() | |
85 { | |
86 unsigned totalNodes = m_counters[TotalLayoutObjectsThatWereLaidOut]; | |
87 if (totalNodes < 100) | |
88 return; | |
89 unsigned usPerNode = (1000.0 * (currentTimeMS() - m_startMs)) / totalNodes; | |
90 Platform::current()->histogramCustomCounts("Layout.MicroSecondsPerNode", usP
erNode, 0, 1000 * 1000, 50); | |
91 unsigned halfTotalNodes = totalNodes / 2; | |
92 const char* histogram = nullptr; | |
93 if (m_counters[LayoutAnalyzer::LayoutObjectsThatAreFloating] > halfTotalNode
s) { | |
94 histogram = "Layout.MicroSecondsPerFloat"; | |
95 } else if (m_counters[LayoutAnalyzer::LayoutObjectsThatAreTableCells] > half
TotalNodes) { | |
96 histogram = "Layout.MicroSecondsPerTD"; | |
97 } else if (m_counters[LayoutAnalyzer::LayoutObjectsThatAreOutOfFlowPositione
d] > halfTotalNodes) { | |
98 histogram = "Layout.MicroSecondsPerPositioned"; | |
99 } else if (m_counters[LayoutAnalyzer::LayoutObjectsThatAreTextAndCanUseTheSi
mpleFontCodePath] > halfTotalNodes) { | |
100 histogram = "Layout.MicroSecondsPerSimpleText"; | |
101 } else if (m_counters[LayoutAnalyzer::LayoutObjectsThatAreTextAndCanNotUseTh
eSimpleFontCodePath] > halfTotalNodes) { | |
102 histogram = "Layout.MicroSecondsPerComplexText"; | |
103 } | |
104 if (histogram) | |
105 Platform::current()->histogramCustomCounts(histogram, usPerNode, 0, 1000
* 1000, 50); | |
106 } | |
107 | |
108 PassRefPtr<TracedValue> LayoutAnalyzer::toTracedValue() | 83 PassRefPtr<TracedValue> LayoutAnalyzer::toTracedValue() |
109 { | 84 { |
110 RefPtr<TracedValue> tracedValue(TracedValue::create()); | 85 RefPtr<TracedValue> tracedValue(TracedValue::create()); |
111 for (size_t i = 0; i < NumCounters; ++i) { | 86 for (size_t i = 0; i < NumCounters; ++i) { |
112 if (m_counters[i] > 0) | 87 if (m_counters[i] > 0) |
113 tracedValue->setInteger(nameForCounter(static_cast<Counter>(i)), m_c
ounters[i]); | 88 tracedValue->setInteger(nameForCounter(static_cast<Counter>(i)), m_c
ounters[i]); |
114 } | 89 } |
115 return tracedValue.release(); | 90 return tracedValue.release(); |
116 } | 91 } |
117 | 92 |
(...skipping 18 matching lines...) Expand all Loading... |
136 case CharactersInLayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath:
return "CharactersInLayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath"; | 111 case CharactersInLayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath:
return "CharactersInLayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath"; |
137 case LayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath: return "LayoutO
bjectsThatAreTextAndCanUseTheSimpleFontCodePath"; | 112 case LayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath: return "LayoutO
bjectsThatAreTextAndCanUseTheSimpleFontCodePath"; |
138 case CharactersInLayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath: ret
urn "CharactersInLayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath"; | 113 case CharactersInLayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath: ret
urn "CharactersInLayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath"; |
139 case TotalLayoutObjectsThatWereLaidOut: return "TotalLayoutObjectsThatWereLa
idOut"; | 114 case TotalLayoutObjectsThatWereLaidOut: return "TotalLayoutObjectsThatWereLa
idOut"; |
140 } | 115 } |
141 ASSERT_NOT_REACHED(); | 116 ASSERT_NOT_REACHED(); |
142 return ""; | 117 return ""; |
143 } | 118 } |
144 | 119 |
145 } // namespace blink | 120 } // namespace blink |
OLD | NEW |