OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef Histogram_h | 5 #ifndef Histogram_h |
6 #define Histogram_h | 6 #define Histogram_h |
7 | 7 |
8 #include "base/metrics/histogram_base.h" | 8 #include "base/metrics/histogram_base.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "platform/PlatformExport.h" | 10 #include "platform/PlatformExport.h" |
11 #include "wtf/CurrentTime.h" | 11 #include "wtf/CurrentTime.h" |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class HistogramBase; | 15 class HistogramBase; |
16 }; | 16 }; |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class PLATFORM_EXPORT CustomCountHistogram { | 20 class PLATFORM_EXPORT CustomCountHistogram { |
21 public: | 21 public: |
| 22 // Min values should be >=1 as emitted 0s still go into the underflow bucket. |
22 CustomCountHistogram(const char* name, | 23 CustomCountHistogram(const char* name, |
23 base::HistogramBase::Sample min, | 24 base::HistogramBase::Sample min, |
24 base::HistogramBase::Sample max, | 25 base::HistogramBase::Sample max, |
25 int32_t bucketCount); | 26 int32_t bucketCount); |
26 void count(base::HistogramBase::Sample); | 27 void count(base::HistogramBase::Sample); |
27 | 28 |
28 protected: | 29 protected: |
29 explicit CustomCountHistogram(base::HistogramBase*); | 30 explicit CustomCountHistogram(base::HistogramBase*); |
30 | 31 |
31 base::HistogramBase* m_histogram; | 32 base::HistogramBase* m_histogram; |
32 }; | 33 }; |
33 | 34 |
34 class PLATFORM_EXPORT BooleanHistogram : public CustomCountHistogram { | 35 class PLATFORM_EXPORT BooleanHistogram : public CustomCountHistogram { |
35 public: | 36 public: |
36 BooleanHistogram(const char* name); | 37 BooleanHistogram(const char* name); |
37 }; | 38 }; |
38 | 39 |
39 class PLATFORM_EXPORT EnumerationHistogram : public CustomCountHistogram { | 40 class PLATFORM_EXPORT EnumerationHistogram : public CustomCountHistogram { |
40 public: | 41 public: |
| 42 // |boundaryValue| must be strictly greater than samples passed to |count|. |
41 EnumerationHistogram(const char* name, | 43 EnumerationHistogram(const char* name, |
42 base::HistogramBase::Sample boundaryValue); | 44 base::HistogramBase::Sample boundaryValue); |
43 }; | 45 }; |
44 | 46 |
45 class PLATFORM_EXPORT SparseHistogram { | 47 class PLATFORM_EXPORT SparseHistogram { |
46 public: | 48 public: |
47 explicit SparseHistogram(const char* name); | 49 explicit SparseHistogram(const char* name); |
48 | 50 |
49 void sample(base::HistogramBase::Sample); | 51 void sample(base::HistogramBase::Sample); |
50 | 52 |
(...skipping 27 matching lines...) Expand all Loading... |
78 // This macro records all times between 0us and 10 seconds. | 80 // This macro records all times between 0us and 10 seconds. |
79 // Do not change this macro without renaming all metrics that use it! | 81 // Do not change this macro without renaming all metrics that use it! |
80 #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \ | 82 #define SCOPED_BLINK_UMA_HISTOGRAM_TIMER(name) \ |
81 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounter, \ | 83 DEFINE_STATIC_LOCAL(CustomCountHistogram, scopedUsCounter, \ |
82 (name, 0, 10000000, 50)); \ | 84 (name, 0, 10000000, 50)); \ |
83 ScopedUsHistogramTimer timer(scopedUsCounter); | 85 ScopedUsHistogramTimer timer(scopedUsCounter); |
84 | 86 |
85 } // namespace blink | 87 } // namespace blink |
86 | 88 |
87 #endif // Histogram_h | 89 #endif // Histogram_h |
OLD | NEW |