Chromium Code Reviews| 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> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 void ExpectBucketCount(const std::string& name, | 47 void ExpectBucketCount(const std::string& name, |
| 48 HistogramBase::Sample sample, | 48 HistogramBase::Sample sample, |
| 49 HistogramBase::Count expected_count) const; | 49 HistogramBase::Count expected_count) const; |
| 50 | 50 |
| 51 // We don't know the values of the samples, but we know how many there are. | 51 // We don't know the values of the samples, but we know how many there are. |
| 52 // This measures the diff from the snapshot taken when this object was | 52 // This measures the diff from the snapshot taken when this object was |
| 53 // constructed. | 53 // constructed. |
| 54 void ExpectTotalCount(const std::string& name, | 54 void ExpectTotalCount(const std::string& name, |
| 55 HistogramBase::Count count) const; | 55 HistogramBase::Count count) const; |
| 56 | 56 |
| 57 // This tests total count of a given histogram, excluding one bucket, given | |
| 58 // the sample id. | |
| 59 void ExpectTotalCountExcept(const std::string& name, | |
| 60 HistogramBase::Sample sample, | |
|
Nico
2017/05/09 19:36:46
s/sample/except/
lunalu1
2017/05/10 19:39:38
Done.
| |
| 61 HistogramBase::Count count) const; | |
| 62 | |
| 57 // We know exact number of samples for buckets corresponding to a time | 63 // We know exact number of samples for buckets corresponding to a time |
| 58 // interval. Other intervals may have samples too. | 64 // interval. Other intervals may have samples too. |
| 59 void ExpectTimeBucketCount(const std::string& name, | 65 void ExpectTimeBucketCount(const std::string& name, |
| 60 TimeDelta sample, | 66 TimeDelta sample, |
| 61 HistogramBase::Count count) const; | 67 HistogramBase::Count count) const; |
| 62 | 68 |
| 63 // Returns a list of all of the buckets recorded since creation of this | 69 // Returns a list of all of the buckets recorded since creation of this |
| 64 // object, as vector<Bucket>, where the Bucket represents the min boundary of | 70 // object, as vector<Bucket>, where the Bucket represents the min boundary of |
| 65 // the bucket and the count of samples recorded to that bucket since creation. | 71 // the bucket and the count of samples recorded to that bucket since creation. |
| 66 // | 72 // |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 Histogram::Count expected_count, | 118 Histogram::Count expected_count, |
| 113 const HistogramSamples& samples) const; | 119 const HistogramSamples& samples) const; |
| 114 | 120 |
| 115 // Verifies that the total number of values recorded for the histogram |name| | 121 // Verifies that the total number of values recorded for the histogram |name| |
| 116 // is |expected_count|. This is checked against |samples| minus the snapshot | 122 // is |expected_count|. This is checked against |samples| minus the snapshot |
| 117 // that was taken for |name|. | 123 // that was taken for |name|. |
| 118 void CheckTotalCount(const std::string& name, | 124 void CheckTotalCount(const std::string& name, |
| 119 Histogram::Count expected_count, | 125 Histogram::Count expected_count, |
| 120 const HistogramSamples& samples) const; | 126 const HistogramSamples& samples) const; |
| 121 | 127 |
| 128 // Verifies that the total number of values recorded for the histogram |name|, | |
| 129 // excluding the value in the |sample| bucket, matches the |expected_count|. | |
| 130 // The histogram's current total counts and its bucket's current value is | |
| 131 // determined from |samples| and is modified based on the snapshot restored | |
| 132 // for histogram |name|. | |
|
Alexei Svitkine (slow)
2017/05/10 15:17:30
I wonder if it wouldn't be better to just have fun
lunalu1
2017/05/10 19:39:38
That was my initial thought. But after seeing that
Alexei Svitkine (slow)
2017/05/10 19:45:19
I agree that it would be different with how the cl
| |
| 133 void CheckTotalCountExcept(const std::string& name, | |
| 134 HistogramBase::Sample sample, | |
|
Nico
2017/05/09 19:36:46
I'd s/sample/except/ here too
lunalu1
2017/05/10 19:39:38
Done.
| |
| 135 Histogram::Count expected_count, | |
| 136 const HistogramSamples& samples) const; | |
| 137 | |
| 122 // Used to determine the histogram changes made during this instance's | 138 // Used to determine the histogram changes made during this instance's |
| 123 // lifecycle. | 139 // lifecycle. |
| 124 std::map<std::string, std::unique_ptr<HistogramSamples>> histograms_snapshot_; | 140 std::map<std::string, std::unique_ptr<HistogramSamples>> histograms_snapshot_; |
| 125 | 141 |
| 126 DISALLOW_COPY_AND_ASSIGN(HistogramTester); | 142 DISALLOW_COPY_AND_ASSIGN(HistogramTester); |
| 127 }; | 143 }; |
| 128 | 144 |
| 129 struct Bucket { | 145 struct Bucket { |
| 130 Bucket(HistogramBase::Sample min, HistogramBase::Count count) | 146 Bucket(HistogramBase::Sample min, HistogramBase::Count count) |
| 131 : min(min), count(count) {} | 147 : min(min), count(count) {} |
| 132 | 148 |
| 133 bool operator==(const Bucket& other) const; | 149 bool operator==(const Bucket& other) const; |
| 134 | 150 |
| 135 HistogramBase::Sample min; | 151 HistogramBase::Sample min; |
| 136 HistogramBase::Count count; | 152 HistogramBase::Count count; |
| 137 }; | 153 }; |
| 138 | 154 |
| 139 void PrintTo(const Bucket& value, std::ostream* os); | 155 void PrintTo(const Bucket& value, std::ostream* os); |
| 140 | 156 |
| 141 } // namespace base | 157 } // namespace base |
| 142 | 158 |
| 143 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ | 159 #endif // BASE_TEST_HISTOGRAM_TESTER_H_ |
| OLD | NEW |