Chromium Code Reviews| Index: base/metrics/histogram_unittest.cc |
| diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc |
| index 58b72480018591f72679a6e1ff036727f25ada2c..668ac1ba7e83ad47bfd107beb97e407bff57d1a8 100644 |
| --- a/base/metrics/histogram_unittest.cc |
| +++ b/base/metrics/histogram_unittest.cc |
| @@ -147,7 +147,7 @@ TEST_P(HistogramTest, NameMatchTest) { |
| EXPECT_EQ(2, samples->GetCount(10)); |
| } |
| -// Check that delta calculations work correct. |
| +// Check that delta calculations work correctly. |
| TEST_P(HistogramTest, DeltaTest) { |
| HistogramBase* histogram = |
| Histogram::FactoryGet("DeltaHistogram", 1, 64, 8, |
| @@ -176,6 +176,32 @@ TEST_P(HistogramTest, DeltaTest) { |
| EXPECT_EQ(0, samples->TotalCount()); |
| } |
| +// Check that final-delta calculations work correctly. |
| +TEST_P(HistogramTest, FinalDeltaTest) { |
| + HistogramBase* histogram = |
| + Histogram::FactoryGet("FinalDeltaHistogram", 1, 64, 8, |
| + HistogramBase::kNoFlags); |
| + histogram->Add(1); |
| + histogram->Add(10); |
| + histogram->Add(50); |
| + |
| + std::unique_ptr<HistogramSamples> samples = histogram->SnapshotDelta(); |
| + EXPECT_EQ(3, samples->TotalCount()); |
| + EXPECT_EQ(1, samples->GetCount(1)); |
| + EXPECT_EQ(1, samples->GetCount(10)); |
| + EXPECT_EQ(1, samples->GetCount(50)); |
| + EXPECT_EQ(samples->TotalCount(), samples->redundant_count()); |
| + |
| + histogram->Add(2); |
| + histogram->Add(50); |
| + |
| + samples = histogram->SnapshotFinalDelta(); |
| + EXPECT_EQ(2, samples->TotalCount()); |
| + EXPECT_EQ(1, samples->GetCount(2)); |
| + EXPECT_EQ(1, samples->GetCount(50)); |
| + EXPECT_EQ(samples->TotalCount(), samples->redundant_count()); |
| +} |
|
Ilya Sherman
2016/05/05 07:22:37
Please test both the case where SnapshotFinalDelta
bcwhite
2016/05/05 16:01:17
What is the benefit of that? There is no differen
Ilya Sherman
2016/05/05 22:22:52
Without looking at the implementation, it's not ha
bcwhite
2016/05/06 16:59:27
I agree which is why the second stage ignored an e
|
| + |
| TEST_P(HistogramTest, ExponentialRangesTest) { |
| // Check that we got a nice exponential when there was enough room. |
| BucketRanges ranges(9); |