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 "DocumentStatisticsCollector.h" | 5 #include "DocumentStatisticsCollector.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/InputTypeNames.h" | 8 #include "core/InputTypeNames.h" |
9 #include "core/dom/ElementTraversal.h" | 9 #include "core/dom/ElementTraversal.h" |
10 #include "core/dom/NodeComputedStyle.h" | 10 #include "core/dom/NodeComputedStyle.h" |
11 #include "core/dom/Text.h" | 11 #include "core/dom/Text.h" |
12 #include "core/frame/FrameHost.h" | 12 #include "core/frame/FrameHost.h" |
13 #include "core/html/HTMLHeadElement.h" | 13 #include "core/html/HTMLHeadElement.h" |
14 #include "core/html/HTMLInputElement.h" | 14 #include "core/html/HTMLInputElement.h" |
15 #include "core/html/HTMLMetaElement.h" | 15 #include "core/html/HTMLMetaElement.h" |
| 16 #include "platform/Histogram.h" |
16 #include "public/platform/Platform.h" | 17 #include "public/platform/Platform.h" |
17 #include "public/platform/WebDistillability.h" | 18 #include "public/platform/WebDistillability.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 using namespace HTMLNames; | 22 using namespace HTMLNames; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Saturate the length of a paragraph to save time. | 26 // Saturate the length of a paragraph to save time. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 double startTime = monotonicallyIncreasingTime(); | 238 double startTime = monotonicallyIncreasingTime(); |
238 | 239 |
239 // This should be cheap since collectStatistics is only called right after l
ayout. | 240 // This should be cheap since collectStatistics is only called right after l
ayout. |
240 document.updateLayoutTreeIfNeeded(); | 241 document.updateLayoutTreeIfNeeded(); |
241 | 242 |
242 // Traverse the DOM tree and collect statistics. | 243 // Traverse the DOM tree and collect statistics. |
243 collectFeatures(*body, features); | 244 collectFeatures(*body, features); |
244 features.openGraph = hasOpenGraphArticle(*head); | 245 features.openGraph = hasOpenGraphArticle(*head); |
245 | 246 |
246 double elapsedTime = monotonicallyIncreasingTime() - startTime; | 247 double elapsedTime = monotonicallyIncreasingTime() - startTime; |
247 Platform::current()->histogramCustomCounts("WebCore.DistillabilityUs", stati
c_cast<int>(1e6 * elapsedTime), 1, 1000000, 50); | 248 |
| 249 DEFINE_STATIC_LOCAL(CustomCountHistogram, distillabilityHistogram, ("WebCore
.DistillabilityUs", 1, 1000000, 50)); |
| 250 distillabilityHistogram.count(static_cast<int>(1e6 * elapsedTime)); |
248 | 251 |
249 return features; | 252 return features; |
250 } | 253 } |
251 | 254 |
252 } // namespace blink | 255 } // namespace blink |
OLD | NEW |