OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Test of Histogram class | 5 // Test of Histogram class |
6 | 6 |
7 #include <climits> | 7 #include <climits> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/bucket_ranges.h" | 13 #include "base/metrics/bucket_ranges.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/metrics/sample_vector.h" | 15 #include "base/metrics/sample_vector.h" |
16 #include "base/metrics/statistics_recorder.h" | 16 #include "base/metrics/statistics_recorder.h" |
17 #include "base/time.h" | 17 #include "base/time.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 using std::vector; | 20 using std::vector; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 | 23 |
| 24 class HistogramTest : public testing::Test { |
| 25 protected: |
| 26 virtual void SetUp() { |
| 27 // Each test will have a clean state (no Histogram / BucketRanges |
| 28 // registered). |
| 29 InitializeStatisticsRecorder(); |
| 30 } |
| 31 |
| 32 virtual void TearDown() { |
| 33 UninitializeStatisticsRecorder(); |
| 34 } |
| 35 |
| 36 void InitializeStatisticsRecorder() { |
| 37 statistics_recorder_ = new StatisticsRecorder(); |
| 38 } |
| 39 |
| 40 void UninitializeStatisticsRecorder() { |
| 41 delete statistics_recorder_; |
| 42 statistics_recorder_ = NULL; |
| 43 } |
| 44 |
| 45 StatisticsRecorder* statistics_recorder_; |
| 46 }; |
| 47 |
24 // Check for basic syntax and use. | 48 // Check for basic syntax and use. |
25 TEST(HistogramTest, BasicTest) { | 49 TEST_F(HistogramTest, BasicTest) { |
26 // Try basic construction | 50 // Try basic construction |
27 Histogram* histogram(Histogram::FactoryGet( | 51 Histogram* histogram(Histogram::FactoryGet( |
28 "TestHistogram", 1, 1000, 10, Histogram::kNoFlags)); | 52 "TestHistogram", 1, 1000, 10, Histogram::kNoFlags)); |
29 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram); | 53 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram); |
30 | 54 |
31 Histogram* linear_histogram(LinearHistogram::FactoryGet( | 55 Histogram* linear_histogram(LinearHistogram::FactoryGet( |
32 "TestLinearHistogram", 1, 1000, 10, Histogram::kNoFlags)); | 56 "TestLinearHistogram", 1, 1000, 10, Histogram::kNoFlags)); |
33 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram); | 57 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram); |
34 | 58 |
35 vector<int> custom_ranges; | 59 vector<int> custom_ranges; |
36 custom_ranges.push_back(1); | 60 custom_ranges.push_back(1); |
37 custom_ranges.push_back(5); | 61 custom_ranges.push_back(5); |
38 Histogram* custom_histogram(CustomHistogram::FactoryGet( | 62 Histogram* custom_histogram(CustomHistogram::FactoryGet( |
39 "TestCustomHistogram", custom_ranges, Histogram::kNoFlags)); | 63 "TestCustomHistogram", custom_ranges, Histogram::kNoFlags)); |
40 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram); | 64 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram); |
41 | 65 |
42 // Use standard macros (but with fixed samples) | 66 // Use standard macros (but with fixed samples) |
43 HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); | 67 HISTOGRAM_TIMES("Test2Histogram", TimeDelta::FromDays(1)); |
44 HISTOGRAM_COUNTS("Test3Histogram", 30); | 68 HISTOGRAM_COUNTS("Test3Histogram", 30); |
45 | 69 |
46 DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1)); | 70 DHISTOGRAM_TIMES("Test4Histogram", TimeDelta::FromDays(1)); |
47 DHISTOGRAM_COUNTS("Test5Histogram", 30); | 71 DHISTOGRAM_COUNTS("Test5Histogram", 30); |
48 | 72 |
49 HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); | 73 HISTOGRAM_ENUMERATION("Test6Histogram", 129, 130); |
50 } | 74 } |
51 | 75 |
52 TEST(HistogramTest, ExponentialRangesTest) { | 76 // Check that the macro correctly matches histograms by name and records their |
| 77 // data together. |
| 78 TEST_F(HistogramTest, NameMatchTest) { |
| 79 HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); |
| 80 HISTOGRAM_PERCENTAGE("DuplicatedHistogram", 10); |
| 81 Histogram* histogram(LinearHistogram::FactoryGet( |
| 82 "DuplicatedHistogram", 1, 101, 102, Histogram::kNoFlags)); |
| 83 scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector(); |
| 84 EXPECT_EQ(2, samples->TotalCount()); |
| 85 EXPECT_EQ(2, samples->GetCountAtIndex(10)); |
| 86 } |
| 87 |
| 88 TEST_F(HistogramTest, ExponentialRangesTest) { |
53 // Check that we got a nice exponential when there was enough rooom. | 89 // Check that we got a nice exponential when there was enough rooom. |
54 BucketRanges ranges(9); | 90 BucketRanges ranges(9); |
55 Histogram::InitializeBucketRanges(1, 64, 8, &ranges); | 91 Histogram::InitializeBucketRanges(1, 64, 8, &ranges); |
56 EXPECT_EQ(0, ranges.range(0)); | 92 EXPECT_EQ(0, ranges.range(0)); |
57 int power_of_2 = 1; | 93 int power_of_2 = 1; |
58 for (int i = 1; i < 8; i++) { | 94 for (int i = 1; i < 8; i++) { |
59 EXPECT_EQ(power_of_2, ranges.range(i)); | 95 EXPECT_EQ(power_of_2, ranges.range(i)); |
60 power_of_2 *= 2; | 96 power_of_2 *= 2; |
61 } | 97 } |
62 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges.range(8)); | 98 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges.range(8)); |
(...skipping 24 matching lines...) Expand all Loading... |
87 EXPECT_EQ(26, ranges2.range(13)); | 123 EXPECT_EQ(26, ranges2.range(13)); |
88 EXPECT_EQ(32, ranges2.range(14)); | 124 EXPECT_EQ(32, ranges2.range(14)); |
89 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges2.range(15)); | 125 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges2.range(15)); |
90 | 126 |
91 // Check the corresponding Histogram will use the correct ranges. | 127 // Check the corresponding Histogram will use the correct ranges. |
92 Histogram* histogram2(Histogram::FactoryGet( | 128 Histogram* histogram2(Histogram::FactoryGet( |
93 "Histogram2", 1, 32, 15, Histogram::kNoFlags)); | 129 "Histogram2", 1, 32, 15, Histogram::kNoFlags)); |
94 EXPECT_TRUE(ranges2.Equals(histogram2->bucket_ranges())); | 130 EXPECT_TRUE(ranges2.Equals(histogram2->bucket_ranges())); |
95 } | 131 } |
96 | 132 |
97 TEST(HistogramTest, LinearRangesTest) { | 133 TEST_F(HistogramTest, LinearRangesTest) { |
98 BucketRanges ranges(9); | 134 BucketRanges ranges(9); |
99 LinearHistogram::InitializeBucketRanges(1, 7, 8, &ranges); | 135 LinearHistogram::InitializeBucketRanges(1, 7, 8, &ranges); |
100 // Gets a nice linear set of bucket ranges. | 136 // Gets a nice linear set of bucket ranges. |
101 for (int i = 0; i < 8; i++) | 137 for (int i = 0; i < 8; i++) |
102 EXPECT_EQ(i, ranges.range(i)); | 138 EXPECT_EQ(i, ranges.range(i)); |
103 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges.range(8)); | 139 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges.range(8)); |
104 // The correspoding LinearHistogram should use the correct ranges. | 140 // The correspoding LinearHistogram should use the correct ranges. |
105 Histogram* histogram( | 141 Histogram* histogram( |
106 LinearHistogram::FactoryGet("Linear", 1, 7, 8, Histogram::kNoFlags)); | 142 LinearHistogram::FactoryGet("Linear", 1, 7, 8, Histogram::kNoFlags)); |
107 EXPECT_TRUE(ranges.Equals(histogram->bucket_ranges())); | 143 EXPECT_TRUE(ranges.Equals(histogram->bucket_ranges())); |
108 | 144 |
109 // Linear ranges are not divisible. | 145 // Linear ranges are not divisible. |
110 BucketRanges ranges2(6); | 146 BucketRanges ranges2(6); |
111 LinearHistogram::InitializeBucketRanges(1, 6, 5, &ranges2); | 147 LinearHistogram::InitializeBucketRanges(1, 6, 5, &ranges2); |
112 EXPECT_EQ(0, ranges2.range(0)); | 148 EXPECT_EQ(0, ranges2.range(0)); |
113 EXPECT_EQ(1, ranges2.range(1)); | 149 EXPECT_EQ(1, ranges2.range(1)); |
114 EXPECT_EQ(3, ranges2.range(2)); | 150 EXPECT_EQ(3, ranges2.range(2)); |
115 EXPECT_EQ(4, ranges2.range(3)); | 151 EXPECT_EQ(4, ranges2.range(3)); |
116 EXPECT_EQ(6, ranges2.range(4)); | 152 EXPECT_EQ(6, ranges2.range(4)); |
117 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges2.range(5)); | 153 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges2.range(5)); |
118 // The correspoding LinearHistogram should use the correct ranges. | 154 // The correspoding LinearHistogram should use the correct ranges. |
119 Histogram* histogram2( | 155 Histogram* histogram2( |
120 LinearHistogram::FactoryGet("Linear2", 1, 6, 5, Histogram::kNoFlags)); | 156 LinearHistogram::FactoryGet("Linear2", 1, 6, 5, Histogram::kNoFlags)); |
121 EXPECT_TRUE(ranges2.Equals(histogram2->bucket_ranges())); | 157 EXPECT_TRUE(ranges2.Equals(histogram2->bucket_ranges())); |
122 } | 158 } |
123 | 159 |
124 TEST(HistogramTest, ArrayToCustomRangesTest) { | 160 TEST_F(HistogramTest, ArrayToCustomRangesTest) { |
125 const HistogramBase::Sample ranges[3] = {5, 10 ,20}; | 161 const HistogramBase::Sample ranges[3] = {5, 10, 20}; |
126 vector<HistogramBase::Sample> ranges_vec = | 162 vector<HistogramBase::Sample> ranges_vec = |
127 CustomHistogram::ArrayToCustomRanges(ranges, 3); | 163 CustomHistogram::ArrayToCustomRanges(ranges, 3); |
128 ASSERT_EQ(6u, ranges_vec.size()); | 164 ASSERT_EQ(6u, ranges_vec.size()); |
129 EXPECT_EQ(5, ranges_vec[0]); | 165 EXPECT_EQ(5, ranges_vec[0]); |
130 EXPECT_EQ(6, ranges_vec[1]); | 166 EXPECT_EQ(6, ranges_vec[1]); |
131 EXPECT_EQ(10, ranges_vec[2]); | 167 EXPECT_EQ(10, ranges_vec[2]); |
132 EXPECT_EQ(11, ranges_vec[3]); | 168 EXPECT_EQ(11, ranges_vec[3]); |
133 EXPECT_EQ(20, ranges_vec[4]); | 169 EXPECT_EQ(20, ranges_vec[4]); |
134 EXPECT_EQ(21, ranges_vec[5]); | 170 EXPECT_EQ(21, ranges_vec[5]); |
135 } | 171 } |
136 | 172 |
137 TEST(HistogramTest, CustomHistogramTest) { | 173 TEST_F(HistogramTest, CustomHistogramTest) { |
138 // A well prepared custom ranges. | 174 // A well prepared custom ranges. |
139 vector<HistogramBase::Sample> custom_ranges; | 175 vector<HistogramBase::Sample> custom_ranges; |
140 custom_ranges.push_back(1); | 176 custom_ranges.push_back(1); |
141 custom_ranges.push_back(2); | 177 custom_ranges.push_back(2); |
142 Histogram* histogram = CustomHistogram::FactoryGet( | 178 Histogram* histogram = CustomHistogram::FactoryGet( |
143 "TestCustomHistogram1", custom_ranges, Histogram::kNoFlags); | 179 "TestCustomHistogram1", custom_ranges, Histogram::kNoFlags); |
144 const BucketRanges* ranges = histogram->bucket_ranges(); | 180 const BucketRanges* ranges = histogram->bucket_ranges(); |
145 ASSERT_EQ(4u, ranges->size()); | 181 ASSERT_EQ(4u, ranges->size()); |
146 EXPECT_EQ(0, ranges->range(0)); // Auto added. | 182 EXPECT_EQ(0, ranges->range(0)); // Auto added. |
147 EXPECT_EQ(1, ranges->range(1)); | 183 EXPECT_EQ(1, ranges->range(1)); |
(...skipping 21 matching lines...) Expand all Loading... |
169 histogram = CustomHistogram::FactoryGet( | 205 histogram = CustomHistogram::FactoryGet( |
170 "TestCustomHistogram3", custom_ranges, Histogram::kNoFlags); | 206 "TestCustomHistogram3", custom_ranges, Histogram::kNoFlags); |
171 ranges = histogram->bucket_ranges(); | 207 ranges = histogram->bucket_ranges(); |
172 ASSERT_EQ(4u, ranges->size()); | 208 ASSERT_EQ(4u, ranges->size()); |
173 EXPECT_EQ(0, ranges->range(0)); | 209 EXPECT_EQ(0, ranges->range(0)); |
174 EXPECT_EQ(1, ranges->range(1)); | 210 EXPECT_EQ(1, ranges->range(1)); |
175 EXPECT_EQ(4, ranges->range(2)); | 211 EXPECT_EQ(4, ranges->range(2)); |
176 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges->range(3)); | 212 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges->range(3)); |
177 } | 213 } |
178 | 214 |
179 TEST(HistogramTest, CustomHistogramWithOnly2Buckets) { | 215 TEST_F(HistogramTest, CustomHistogramWithOnly2Buckets) { |
180 // This test exploits the fact that the CustomHistogram can have 2 buckets, | 216 // This test exploits the fact that the CustomHistogram can have 2 buckets, |
181 // while the base class Histogram is *supposed* to have at least 3 buckets. | 217 // while the base class Histogram is *supposed* to have at least 3 buckets. |
182 // We should probably change the restriction on the base class (or not inherit | 218 // We should probably change the restriction on the base class (or not inherit |
183 // the base class!). | 219 // the base class!). |
184 | 220 |
185 vector<HistogramBase::Sample> custom_ranges; | 221 vector<HistogramBase::Sample> custom_ranges; |
186 custom_ranges.push_back(4); | 222 custom_ranges.push_back(4); |
187 | 223 |
188 Histogram* histogram = CustomHistogram::FactoryGet( | 224 Histogram* histogram = CustomHistogram::FactoryGet( |
189 "2BucketsCustomHistogram", custom_ranges, Histogram::kNoFlags); | 225 "2BucketsCustomHistogram", custom_ranges, Histogram::kNoFlags); |
190 const BucketRanges* ranges = histogram->bucket_ranges(); | 226 const BucketRanges* ranges = histogram->bucket_ranges(); |
191 ASSERT_EQ(3u, ranges->size()); | 227 ASSERT_EQ(3u, ranges->size()); |
192 EXPECT_EQ(0, ranges->range(0)); | 228 EXPECT_EQ(0, ranges->range(0)); |
193 EXPECT_EQ(4, ranges->range(1)); | 229 EXPECT_EQ(4, ranges->range(1)); |
194 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges->range(2)); | 230 EXPECT_EQ(HistogramBase::kSampleType_MAX, ranges->range(2)); |
195 } | 231 } |
196 | 232 |
197 // Make sure histogram handles out-of-bounds data gracefully. | 233 // Make sure histogram handles out-of-bounds data gracefully. |
198 TEST(HistogramTest, BoundsTest) { | 234 TEST_F(HistogramTest, BoundsTest) { |
199 const size_t kBucketCount = 50; | 235 const size_t kBucketCount = 50; |
200 Histogram* histogram(Histogram::FactoryGet( | 236 Histogram* histogram(Histogram::FactoryGet( |
201 "Bounded", 10, 100, kBucketCount, Histogram::kNoFlags)); | 237 "Bounded", 10, 100, kBucketCount, Histogram::kNoFlags)); |
202 | 238 |
203 // Put two samples "out of bounds" above and below. | 239 // Put two samples "out of bounds" above and below. |
204 histogram->Add(5); | 240 histogram->Add(5); |
205 histogram->Add(-50); | 241 histogram->Add(-50); |
206 | 242 |
207 histogram->Add(100); | 243 histogram->Add(100); |
208 histogram->Add(10000); | 244 histogram->Add(10000); |
(...skipping 25 matching lines...) Expand all Loading... |
234 scoped_ptr<SampleVector> custom_samples = | 270 scoped_ptr<SampleVector> custom_samples = |
235 test_custom_histogram->SnapshotSampleVector(); | 271 test_custom_histogram->SnapshotSampleVector(); |
236 EXPECT_EQ(2, custom_samples->GetCountAtIndex(0)); | 272 EXPECT_EQ(2, custom_samples->GetCountAtIndex(0)); |
237 EXPECT_EQ(0, custom_samples->GetCountAtIndex(1)); | 273 EXPECT_EQ(0, custom_samples->GetCountAtIndex(1)); |
238 size_t bucket_count = test_custom_histogram->bucket_count(); | 274 size_t bucket_count = test_custom_histogram->bucket_count(); |
239 EXPECT_EQ(0, custom_samples->GetCountAtIndex(bucket_count - 2)); | 275 EXPECT_EQ(0, custom_samples->GetCountAtIndex(bucket_count - 2)); |
240 EXPECT_EQ(3, custom_samples->GetCountAtIndex(bucket_count - 1)); | 276 EXPECT_EQ(3, custom_samples->GetCountAtIndex(bucket_count - 1)); |
241 } | 277 } |
242 | 278 |
243 // Check to be sure samples land as expected is "correct" buckets. | 279 // Check to be sure samples land as expected is "correct" buckets. |
244 TEST(HistogramTest, BucketPlacementTest) { | 280 TEST_F(HistogramTest, BucketPlacementTest) { |
245 Histogram* histogram(Histogram::FactoryGet( | 281 Histogram* histogram(Histogram::FactoryGet( |
246 "Histogram", 1, 64, 8, Histogram::kNoFlags)); | 282 "Histogram", 1, 64, 8, Histogram::kNoFlags)); |
247 | 283 |
248 // Add i+1 samples to the i'th bucket. | 284 // Add i+1 samples to the i'th bucket. |
249 histogram->Add(0); | 285 histogram->Add(0); |
250 int power_of_2 = 1; | 286 int power_of_2 = 1; |
251 for (int i = 1; i < 8; i++) { | 287 for (int i = 1; i < 8; i++) { |
252 for (int j = 0; j <= i; j++) | 288 for (int j = 0; j <= i; j++) |
253 histogram->Add(power_of_2); | 289 histogram->Add(power_of_2); |
254 power_of_2 *= 2; | 290 power_of_2 *= 2; |
255 } | 291 } |
256 | 292 |
257 // Check to see that the bucket counts reflect our additions. | 293 // Check to see that the bucket counts reflect our additions. |
258 scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector(); | 294 scoped_ptr<SampleVector> samples = histogram->SnapshotSampleVector(); |
259 for (int i = 0; i < 8; i++) | 295 for (int i = 0; i < 8; i++) |
260 EXPECT_EQ(i + 1, samples->GetCountAtIndex(i)); | 296 EXPECT_EQ(i + 1, samples->GetCountAtIndex(i)); |
261 } | 297 } |
262 | 298 |
263 TEST(HistogramTest, CorruptSampleCounts) { | 299 TEST_F(HistogramTest, CorruptSampleCounts) { |
264 Histogram* histogram(Histogram::FactoryGet( | 300 Histogram* histogram(Histogram::FactoryGet( |
265 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file. | 301 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file. |
266 | 302 |
267 // Add some samples. | 303 // Add some samples. |
268 histogram->Add(20); | 304 histogram->Add(20); |
269 histogram->Add(40); | 305 histogram->Add(40); |
270 | 306 |
271 scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector(); | 307 scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector(); |
272 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, | 308 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, |
273 histogram->FindCorruption(*snapshot)); | 309 histogram->FindCorruption(*snapshot)); |
274 EXPECT_EQ(2, snapshot->redundant_count()); | 310 EXPECT_EQ(2, snapshot->redundant_count()); |
275 EXPECT_EQ(2, snapshot->TotalCount()); | 311 EXPECT_EQ(2, snapshot->TotalCount()); |
276 | 312 |
277 snapshot->counts_[3] += 100; // Sample count won't match redundant count. | 313 snapshot->counts_[3] += 100; // Sample count won't match redundant count. |
278 EXPECT_EQ(Histogram::COUNT_LOW_ERROR, | 314 EXPECT_EQ(Histogram::COUNT_LOW_ERROR, |
279 histogram->FindCorruption(*snapshot)); | 315 histogram->FindCorruption(*snapshot)); |
280 snapshot->counts_[2] -= 200; | 316 snapshot->counts_[2] -= 200; |
281 EXPECT_EQ(Histogram::COUNT_HIGH_ERROR, | 317 EXPECT_EQ(Histogram::COUNT_HIGH_ERROR, |
282 histogram->FindCorruption(*snapshot)); | 318 histogram->FindCorruption(*snapshot)); |
283 | 319 |
284 // But we can't spot a corruption if it is compensated for. | 320 // But we can't spot a corruption if it is compensated for. |
285 snapshot->counts_[1] += 100; | 321 snapshot->counts_[1] += 100; |
286 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, | 322 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, |
287 histogram->FindCorruption(*snapshot)); | 323 histogram->FindCorruption(*snapshot)); |
288 } | 324 } |
289 | 325 |
290 TEST(HistogramTest, CorruptBucketBounds) { | 326 TEST_F(HistogramTest, CorruptBucketBounds) { |
291 Histogram* histogram(Histogram::FactoryGet( | 327 Histogram* histogram(Histogram::FactoryGet( |
292 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file. | 328 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file. |
293 | 329 |
294 scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector(); | 330 scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector(); |
295 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, | 331 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, |
296 histogram->FindCorruption(*snapshot)); | 332 histogram->FindCorruption(*snapshot)); |
297 | 333 |
298 BucketRanges* bucket_ranges = | 334 BucketRanges* bucket_ranges = |
299 const_cast<BucketRanges*>(histogram->bucket_ranges()); | 335 const_cast<BucketRanges*>(histogram->bucket_ranges()); |
300 HistogramBase::Sample tmp = bucket_ranges->range(1); | 336 HistogramBase::Sample tmp = bucket_ranges->range(1); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // CustomHistogram needs at least 1 valid range. | 395 // CustomHistogram needs at least 1 valid range. |
360 custom_ranges.clear(); | 396 custom_ranges.clear(); |
361 custom_ranges.push_back(0); | 397 custom_ranges.push_back(0); |
362 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, | 398 EXPECT_DEATH(CustomHistogram::FactoryGet("BadRangesCustom3", custom_ranges, |
363 Histogram::kNoFlags), | 399 Histogram::kNoFlags), |
364 ""); | 400 ""); |
365 } | 401 } |
366 #endif | 402 #endif |
367 | 403 |
368 } // namespace base | 404 } // namespace base |
OLD | NEW |