Home | History | Annotate | Download | only in metrics

Lines Matching defs:histogram

5 // Test of Histogram class
7 #include "base/metrics/histogram.h"
21 Histogram* histogram(Histogram::FactoryGet(
22 "TestHistogram", 1, 1000, 10, Histogram::kNoFlags));
23 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram);
24 Histogram* histogram1(Histogram::FactoryGet(
25 "Test1Histogram", 1, 1000, 10, Histogram::kNoFlags));
26 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram1);
27 EXPECT_NE(histogram, histogram1);
30 Histogram* linear_histogram(LinearHistogram::FactoryGet(
31 "TestLinearHistogram", 1, 1000, 10, Histogram::kNoFlags));
32 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram);
33 Histogram* linear_histogram1(LinearHistogram::FactoryGet(
34 "Test1LinearHistogram", 1, 1000, 10, Histogram::kNoFlags));
35 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram1);
44 Histogram* custom_histogram(CustomHistogram::FactoryGet(
45 "TestCustomHistogram", custom_ranges, Histogram::kNoFlags));
46 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram);
47 Histogram* custom_histogram1(CustomHistogram::FactoryGet(
48 "Test1CustomHistogram", custom_ranges, Histogram::kNoFlags));
49 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram1);
61 Histogram::SampleSet sample1;
62 Histogram::SampleSet sample2;
66 Histogram::SampleSet sample3(sample1);
83 Histogram* histogram(Histogram::FactoryGet(
84 "TestHistogram", 1, 1000, 10, Histogram::kNoFlags));
85 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram);
89 Histogram* histogram1(Histogram::FactoryGet(
90 "Test1Histogram", 1, 1000, 10, Histogram::kNoFlags));
91 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), histogram1);
96 Histogram* linear_histogram(LinearHistogram::FactoryGet(
97 "TestLinearHistogram", 1, 1000, 10, Histogram::kNoFlags));
98 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram);
103 Histogram* linear_histogram1(LinearHistogram::FactoryGet(
104 "Test1LinearHistogram", 1, 1000, 10, Histogram::kNoFlags));
105 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), linear_histogram1);
116 Histogram* custom_histogram(CustomHistogram::FactoryGet(
117 "TestCustomHistogram", custom_ranges, Histogram::kNoFlags));
118 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram);
119 Histogram* custom_histogram1(CustomHistogram::FactoryGet(
120 "TestCustomHistogram", custom_ranges, Histogram::kNoFlags));
121 EXPECT_NE(reinterpret_cast<Histogram*>(NULL), custom_histogram1);
157 Histogram* histogram(Histogram::FactoryGet(
158 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file.
160 EXPECT_EQ(0, histogram->ranges(0));
163 EXPECT_EQ(power_of_2, histogram->ranges(i));
166 EXPECT_EQ(INT_MAX, histogram->ranges(8));
168 Histogram* short_histogram(Histogram::FactoryGet(
169 "Histogram Shortened", 1, 7, 8, Histogram::kNoFlags));
170 // Check that when the number of buckets is short, we get a linear histogram
176 Histogram* linear_histogram(LinearHistogram::FactoryGet(
177 "Linear", 1, 7, 8, Histogram::kNoFlags));
183 Histogram* linear_broad_histogram(LinearHistogram::FactoryGet(
184 "Linear widened", 2, 14, 8, Histogram::kNoFlags));
190 Histogram* transitioning_histogram(Histogram::FactoryGet(
191 "LinearAndExponential", 1, 32, 15, Histogram::kNoFlags));
216 Histogram* test_custom_histogram(CustomHistogram::FactoryGet(
217 "TestCustomRangeHistogram", custom_ranges, Histogram::kNoFlags));
239 Histogram* test_custom_histogram(CustomHistogram::FactoryGet(
240 "TestCustomRangeHistogram", custom_ranges, Histogram::kNoFlags));
260 Histogram* unsorted_histogram(CustomHistogram::FactoryGet(
261 "TestCustomUnsortedDupedHistogram", custom_ranges, Histogram::kNoFlags));
269 // Make sure histogram handles out-of-bounds data gracefully.
272 Histogram* histogram(Histogram::FactoryGet(
273 "Bounded", 10, 100, kBucketCount, Histogram::kNoFlags));
276 histogram->Add(5);
277 histogram->Add(-50);
279 histogram->Add(100);
280 histogram->Add(10000);
283 Histogram::SampleSet sample;
284 histogram->SnapshotSample(&sample);
287 size_t array_size = histogram->bucket_count();
295 Histogram* histogram(Histogram::FactoryGet(
296 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file.
299 EXPECT_EQ(0, histogram->ranges(0));
302 EXPECT_EQ(power_of_2, histogram->ranges(i));
305 EXPECT_EQ(INT_MAX, histogram->ranges(8));
308 histogram->Add(0);
312 histogram->Add(power_of_2);
318 Histogram::SampleSet sample;
319 histogram->SnapshotSample(&sample);
320 EXPECT_EQ(INT_MAX, histogram->ranges(8));
330 // internals of the histogram and/or sampleset.
332 Histogram* histogram(Histogram::FactoryGet(
333 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file.
335 EXPECT_EQ(0, histogram->sample_.redundant_count());
336 histogram->Add(20); // Add some samples.
337 histogram->Add(40);
338 EXPECT_EQ(2, histogram->sample_.redundant_count());
340 Histogram::SampleSet snapshot;
341 histogram->SnapshotSample(&snapshot);
342 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, 0);
343 EXPECT_EQ(0, histogram->FindCorruption(snapshot)); // No default corruption.
347 EXPECT_EQ(Histogram::COUNT_LOW_ERROR, histogram->FindCorruption(snapshot));
349 EXPECT_EQ(Histogram::COUNT_HIGH_ERROR, histogram->FindCorruption(snapshot));
353 EXPECT_EQ(0, histogram->FindCorruption(snapshot));
357 Histogram* histogram(Histogram::FactoryGet(
358 "Histogram", 1, 64, 8, Histogram::kNoFlags)); // As per header file.
360 Histogram::SampleSet snapshot;
361 histogram->SnapshotSample(&snapshot);
362 EXPECT_EQ(Histogram::NO_INCONSISTENCIES, 0);
363 EXPECT_EQ(0, histogram->FindCorruption(snapshot)); // No default corruption.
365 std::swap(histogram->ranges_[1], histogram->ranges_[2]);
366 EXPECT_EQ(Histogram::BUCKET_ORDER_ERROR | Histogram::RANGE_CHECKSUM_ERROR,
367 histogram->FindCorruption(snapshot));
369 std::swap(histogram->ranges_[1], histogram->ranges_[2]);
370 EXPECT_EQ(0, histogram->FindCorruption(snapshot));
372 ++histogram->ranges_[3];
373 EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
374 histogram->FindCorruption(snapshot));
377 --histogram->ranges_[4];
378 EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
379 histogram->FindCorruption(snapshot));
381 // Repair histogram so that destructor won't DCHECK().
382 --histogram->ranges_[3];
383 ++histogram->ranges_[4];
398 EXPECT_EQ(Histogram::kCrcTable[i], checksum);