OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 BASE_TEST_HISTOGRAM_TESTER_H_ | 5 #ifndef BASE_TEST_HISTOGRAM_TESTER_H_ |
6 #define BASE_TEST_HISTOGRAM_TESTER_H_ | 6 #define BASE_TEST_HISTOGRAM_TESTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <ostream> | 10 #include <ostream> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/metrics/histogram_base.h" | 17 #include "base/metrics/histogram_base.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 struct Bucket; | 22 struct Bucket; |
23 class HistogramSamples; | 23 class HistogramSamples; |
24 | 24 |
25 // HistogramTester provides a simple interface for examining histograms, UMA | 25 // HistogramTester provides a simple interface for examining histograms, UMA |
26 // or otherwise. Tests can use this interface to verify that histogram data is | 26 // or otherwise. Tests can use this interface to verify that histogram data is |
27 // getting logged as intended. | 27 // getting logged as intended. |
| 28 // |
| 29 // Note: When using this class from a browser test, one might have to call |
| 30 // SubprocessMetricsProvider::MergeHistogramDeltasForTesting() to sync the |
| 31 // histogram data between the renderer and browser processes. |
28 class HistogramTester { | 32 class HistogramTester { |
29 public: | 33 public: |
30 using CountsMap = std::map<std::string, HistogramBase::Count>; | 34 using CountsMap = std::map<std::string, HistogramBase::Count>; |
31 | 35 |
32 // The constructor will call StatisticsRecorder::Initialize() for you. Also, | 36 // The constructor will call StatisticsRecorder::Initialize() for you. Also, |
33 // this takes a snapshot of all current histograms counts. | 37 // this takes a snapshot of all current histograms counts. |
34 HistogramTester(); | 38 HistogramTester(); |
35 ~HistogramTester(); | 39 ~HistogramTester(); |
36 | 40 |
37 // We know the exact number of samples in a bucket, and that no other bucket | 41 // We know the exact number of samples in a bucket, and that no other bucket |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 150 |
147 HistogramBase::Sample min; | 151 HistogramBase::Sample min; |
148 HistogramBase::Count count; | 152 HistogramBase::Count count; |
149 }; | 153 }; |
150 | 154 |
151 void PrintTo(const Bucket& value, std::ostream* os); | 155 void PrintTo(const Bucket& value, std::ostream* os); |
152 | 156 |
153 } // namespace base | 157 } // namespace base |
154 | 158 |
155 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ | 159 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ |
OLD | NEW |