1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker
5*635a8641SAndroid Build Coastguard Worker #include <vector>
6*635a8641SAndroid Build Coastguard Worker
7*635a8641SAndroid Build Coastguard Worker #include "base/metrics/histogram.h"
8*635a8641SAndroid Build Coastguard Worker #include "base/metrics/histogram_base.h"
9*635a8641SAndroid Build Coastguard Worker #include "base/metrics/sample_vector.h"
10*635a8641SAndroid Build Coastguard Worker #include "base/metrics/sparse_histogram.h"
11*635a8641SAndroid Build Coastguard Worker #include "base/metrics/statistics_recorder.h"
12*635a8641SAndroid Build Coastguard Worker #include "base/pickle.h"
13*635a8641SAndroid Build Coastguard Worker #include "testing/gtest/include/gtest/gtest.h"
14*635a8641SAndroid Build Coastguard Worker
15*635a8641SAndroid Build Coastguard Worker namespace base {
16*635a8641SAndroid Build Coastguard Worker
17*635a8641SAndroid Build Coastguard Worker class HistogramBaseTest : public testing::Test {
18*635a8641SAndroid Build Coastguard Worker protected:
HistogramBaseTest()19*635a8641SAndroid Build Coastguard Worker HistogramBaseTest() {
20*635a8641SAndroid Build Coastguard Worker // Each test will have a clean state (no Histogram / BucketRanges
21*635a8641SAndroid Build Coastguard Worker // registered).
22*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
23*635a8641SAndroid Build Coastguard Worker }
24*635a8641SAndroid Build Coastguard Worker
25*635a8641SAndroid Build Coastguard Worker ~HistogramBaseTest() override = default;
26*635a8641SAndroid Build Coastguard Worker
ResetStatisticsRecorder()27*635a8641SAndroid Build Coastguard Worker void ResetStatisticsRecorder() {
28*635a8641SAndroid Build Coastguard Worker // It is necessary to fully destruct any existing StatisticsRecorder
29*635a8641SAndroid Build Coastguard Worker // before creating a new one.
30*635a8641SAndroid Build Coastguard Worker statistics_recorder_.reset();
31*635a8641SAndroid Build Coastguard Worker statistics_recorder_ = StatisticsRecorder::CreateTemporaryForTesting();
32*635a8641SAndroid Build Coastguard Worker }
33*635a8641SAndroid Build Coastguard Worker
34*635a8641SAndroid Build Coastguard Worker private:
35*635a8641SAndroid Build Coastguard Worker std::unique_ptr<StatisticsRecorder> statistics_recorder_;
36*635a8641SAndroid Build Coastguard Worker
37*635a8641SAndroid Build Coastguard Worker DISALLOW_COPY_AND_ASSIGN(HistogramBaseTest);
38*635a8641SAndroid Build Coastguard Worker };
39*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,DeserializeHistogram)40*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, DeserializeHistogram) {
41*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = Histogram::FactoryGet(
42*635a8641SAndroid Build Coastguard Worker "TestHistogram", 1, 1000, 10,
43*635a8641SAndroid Build Coastguard Worker (HistogramBase::kUmaTargetedHistogramFlag |
44*635a8641SAndroid Build Coastguard Worker HistogramBase::kIPCSerializationSourceFlag));
45*635a8641SAndroid Build Coastguard Worker
46*635a8641SAndroid Build Coastguard Worker Pickle pickle;
47*635a8641SAndroid Build Coastguard Worker histogram->SerializeInfo(&pickle);
48*635a8641SAndroid Build Coastguard Worker
49*635a8641SAndroid Build Coastguard Worker PickleIterator iter(pickle);
50*635a8641SAndroid Build Coastguard Worker HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
51*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(histogram, deserialized);
52*635a8641SAndroid Build Coastguard Worker
53*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
54*635a8641SAndroid Build Coastguard Worker
55*635a8641SAndroid Build Coastguard Worker PickleIterator iter2(pickle);
56*635a8641SAndroid Build Coastguard Worker deserialized = DeserializeHistogramInfo(&iter2);
57*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized);
58*635a8641SAndroid Build Coastguard Worker EXPECT_NE(histogram, deserialized);
59*635a8641SAndroid Build Coastguard Worker EXPECT_EQ("TestHistogram", StringPiece(deserialized->histogram_name()));
60*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized->HasConstructionArguments(1, 1000, 10));
61*635a8641SAndroid Build Coastguard Worker
62*635a8641SAndroid Build Coastguard Worker // kIPCSerializationSourceFlag will be cleared.
63*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, deserialized->flags());
64*635a8641SAndroid Build Coastguard Worker }
65*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,DeserializeLinearHistogram)66*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, DeserializeLinearHistogram) {
67*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = LinearHistogram::FactoryGet(
68*635a8641SAndroid Build Coastguard Worker "TestHistogram", 1, 1000, 10,
69*635a8641SAndroid Build Coastguard Worker HistogramBase::kIPCSerializationSourceFlag);
70*635a8641SAndroid Build Coastguard Worker
71*635a8641SAndroid Build Coastguard Worker Pickle pickle;
72*635a8641SAndroid Build Coastguard Worker histogram->SerializeInfo(&pickle);
73*635a8641SAndroid Build Coastguard Worker
74*635a8641SAndroid Build Coastguard Worker PickleIterator iter(pickle);
75*635a8641SAndroid Build Coastguard Worker HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
76*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(histogram, deserialized);
77*635a8641SAndroid Build Coastguard Worker
78*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
79*635a8641SAndroid Build Coastguard Worker
80*635a8641SAndroid Build Coastguard Worker PickleIterator iter2(pickle);
81*635a8641SAndroid Build Coastguard Worker deserialized = DeserializeHistogramInfo(&iter2);
82*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized);
83*635a8641SAndroid Build Coastguard Worker EXPECT_NE(histogram, deserialized);
84*635a8641SAndroid Build Coastguard Worker EXPECT_EQ("TestHistogram", StringPiece(deserialized->histogram_name()));
85*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized->HasConstructionArguments(1, 1000, 10));
86*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(0, deserialized->flags());
87*635a8641SAndroid Build Coastguard Worker }
88*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,DeserializeBooleanHistogram)89*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, DeserializeBooleanHistogram) {
90*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = BooleanHistogram::FactoryGet(
91*635a8641SAndroid Build Coastguard Worker "TestHistogram", HistogramBase::kIPCSerializationSourceFlag);
92*635a8641SAndroid Build Coastguard Worker
93*635a8641SAndroid Build Coastguard Worker Pickle pickle;
94*635a8641SAndroid Build Coastguard Worker histogram->SerializeInfo(&pickle);
95*635a8641SAndroid Build Coastguard Worker
96*635a8641SAndroid Build Coastguard Worker PickleIterator iter(pickle);
97*635a8641SAndroid Build Coastguard Worker HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
98*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(histogram, deserialized);
99*635a8641SAndroid Build Coastguard Worker
100*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
101*635a8641SAndroid Build Coastguard Worker
102*635a8641SAndroid Build Coastguard Worker PickleIterator iter2(pickle);
103*635a8641SAndroid Build Coastguard Worker deserialized = DeserializeHistogramInfo(&iter2);
104*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized);
105*635a8641SAndroid Build Coastguard Worker EXPECT_NE(histogram, deserialized);
106*635a8641SAndroid Build Coastguard Worker EXPECT_EQ("TestHistogram", StringPiece(deserialized->histogram_name()));
107*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized->HasConstructionArguments(1, 2, 3));
108*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(0, deserialized->flags());
109*635a8641SAndroid Build Coastguard Worker }
110*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,DeserializeCustomHistogram)111*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, DeserializeCustomHistogram) {
112*635a8641SAndroid Build Coastguard Worker std::vector<HistogramBase::Sample> ranges;
113*635a8641SAndroid Build Coastguard Worker ranges.push_back(13);
114*635a8641SAndroid Build Coastguard Worker ranges.push_back(5);
115*635a8641SAndroid Build Coastguard Worker ranges.push_back(9);
116*635a8641SAndroid Build Coastguard Worker
117*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = CustomHistogram::FactoryGet(
118*635a8641SAndroid Build Coastguard Worker "TestHistogram", ranges, HistogramBase::kIPCSerializationSourceFlag);
119*635a8641SAndroid Build Coastguard Worker
120*635a8641SAndroid Build Coastguard Worker Pickle pickle;
121*635a8641SAndroid Build Coastguard Worker histogram->SerializeInfo(&pickle);
122*635a8641SAndroid Build Coastguard Worker
123*635a8641SAndroid Build Coastguard Worker PickleIterator iter(pickle);
124*635a8641SAndroid Build Coastguard Worker HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
125*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(histogram, deserialized);
126*635a8641SAndroid Build Coastguard Worker
127*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
128*635a8641SAndroid Build Coastguard Worker
129*635a8641SAndroid Build Coastguard Worker PickleIterator iter2(pickle);
130*635a8641SAndroid Build Coastguard Worker deserialized = DeserializeHistogramInfo(&iter2);
131*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized);
132*635a8641SAndroid Build Coastguard Worker EXPECT_NE(histogram, deserialized);
133*635a8641SAndroid Build Coastguard Worker EXPECT_EQ("TestHistogram", StringPiece(deserialized->histogram_name()));
134*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized->HasConstructionArguments(5, 13, 4));
135*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(0, deserialized->flags());
136*635a8641SAndroid Build Coastguard Worker }
137*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,DeserializeSparseHistogram)138*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, DeserializeSparseHistogram) {
139*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = SparseHistogram::FactoryGet(
140*635a8641SAndroid Build Coastguard Worker "TestHistogram", HistogramBase::kIPCSerializationSourceFlag);
141*635a8641SAndroid Build Coastguard Worker
142*635a8641SAndroid Build Coastguard Worker Pickle pickle;
143*635a8641SAndroid Build Coastguard Worker histogram->SerializeInfo(&pickle);
144*635a8641SAndroid Build Coastguard Worker
145*635a8641SAndroid Build Coastguard Worker PickleIterator iter(pickle);
146*635a8641SAndroid Build Coastguard Worker HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
147*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(histogram, deserialized);
148*635a8641SAndroid Build Coastguard Worker
149*635a8641SAndroid Build Coastguard Worker ResetStatisticsRecorder();
150*635a8641SAndroid Build Coastguard Worker
151*635a8641SAndroid Build Coastguard Worker PickleIterator iter2(pickle);
152*635a8641SAndroid Build Coastguard Worker deserialized = DeserializeHistogramInfo(&iter2);
153*635a8641SAndroid Build Coastguard Worker EXPECT_TRUE(deserialized);
154*635a8641SAndroid Build Coastguard Worker EXPECT_NE(histogram, deserialized);
155*635a8641SAndroid Build Coastguard Worker EXPECT_EQ("TestHistogram", StringPiece(deserialized->histogram_name()));
156*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(0, deserialized->flags());
157*635a8641SAndroid Build Coastguard Worker }
158*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,AddKilo)159*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, AddKilo) {
160*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram =
161*635a8641SAndroid Build Coastguard Worker LinearHistogram::FactoryGet("TestAddKiloHistogram", 1, 1000, 100, 0);
162*635a8641SAndroid Build Coastguard Worker
163*635a8641SAndroid Build Coastguard Worker histogram->AddKilo(100, 1000);
164*635a8641SAndroid Build Coastguard Worker histogram->AddKilo(200, 2000);
165*635a8641SAndroid Build Coastguard Worker histogram->AddKilo(300, 1500);
166*635a8641SAndroid Build Coastguard Worker
167*635a8641SAndroid Build Coastguard Worker std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
168*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(1, samples->GetCount(100));
169*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(2, samples->GetCount(200));
170*635a8641SAndroid Build Coastguard Worker EXPECT_LE(1, samples->GetCount(300));
171*635a8641SAndroid Build Coastguard Worker EXPECT_GE(2, samples->GetCount(300));
172*635a8641SAndroid Build Coastguard Worker }
173*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,AddKiB)174*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, AddKiB) {
175*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram =
176*635a8641SAndroid Build Coastguard Worker LinearHistogram::FactoryGet("TestAddKiBHistogram", 1, 1000, 100, 0);
177*635a8641SAndroid Build Coastguard Worker
178*635a8641SAndroid Build Coastguard Worker histogram->AddKiB(100, 1024);
179*635a8641SAndroid Build Coastguard Worker histogram->AddKiB(200, 2048);
180*635a8641SAndroid Build Coastguard Worker histogram->AddKiB(300, 1536);
181*635a8641SAndroid Build Coastguard Worker
182*635a8641SAndroid Build Coastguard Worker std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
183*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(1, samples->GetCount(100));
184*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(2, samples->GetCount(200));
185*635a8641SAndroid Build Coastguard Worker EXPECT_LE(1, samples->GetCount(300));
186*635a8641SAndroid Build Coastguard Worker EXPECT_GE(2, samples->GetCount(300));
187*635a8641SAndroid Build Coastguard Worker }
188*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,AddTimeMillisecondsGranularityOverflow)189*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, AddTimeMillisecondsGranularityOverflow) {
190*635a8641SAndroid Build Coastguard Worker const HistogramBase::Sample sample_max =
191*635a8641SAndroid Build Coastguard Worker std::numeric_limits<HistogramBase::Sample>::max() / 2;
192*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = LinearHistogram::FactoryGet(
193*635a8641SAndroid Build Coastguard Worker "TestAddTimeMillisecondsGranularity1", 1, sample_max, 100, 0);
194*635a8641SAndroid Build Coastguard Worker int64_t large_positive = std::numeric_limits<int64_t>::max();
195*635a8641SAndroid Build Coastguard Worker // |add_count| is the number of large values that have been added to the
196*635a8641SAndroid Build Coastguard Worker // histogram. We consider a number to be 'large' if it cannot be represented
197*635a8641SAndroid Build Coastguard Worker // in a HistogramBase::Sample.
198*635a8641SAndroid Build Coastguard Worker int add_count = 0;
199*635a8641SAndroid Build Coastguard Worker while (large_positive > std::numeric_limits<HistogramBase::Sample>::max()) {
200*635a8641SAndroid Build Coastguard Worker // Add the TimeDelta corresponding to |large_positive| milliseconds to the
201*635a8641SAndroid Build Coastguard Worker // histogram.
202*635a8641SAndroid Build Coastguard Worker histogram->AddTimeMillisecondsGranularity(
203*635a8641SAndroid Build Coastguard Worker TimeDelta::FromMilliseconds(large_positive));
204*635a8641SAndroid Build Coastguard Worker ++add_count;
205*635a8641SAndroid Build Coastguard Worker // Reduce the value of |large_positive|. The choice of 7 here is
206*635a8641SAndroid Build Coastguard Worker // arbitrary.
207*635a8641SAndroid Build Coastguard Worker large_positive /= 7;
208*635a8641SAndroid Build Coastguard Worker }
209*635a8641SAndroid Build Coastguard Worker std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
210*635a8641SAndroid Build Coastguard Worker // All of the reported values must have gone into the max overflow bucket.
211*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(add_count, samples->GetCount(sample_max));
212*635a8641SAndroid Build Coastguard Worker
213*635a8641SAndroid Build Coastguard Worker // We now perform the analoguous operations, now with negative values with a
214*635a8641SAndroid Build Coastguard Worker // large absolute value.
215*635a8641SAndroid Build Coastguard Worker histogram = LinearHistogram::FactoryGet("TestAddTimeMillisecondsGranularity2",
216*635a8641SAndroid Build Coastguard Worker 1, sample_max, 100, 0);
217*635a8641SAndroid Build Coastguard Worker int64_t large_negative = std::numeric_limits<int64_t>::min();
218*635a8641SAndroid Build Coastguard Worker add_count = 0;
219*635a8641SAndroid Build Coastguard Worker while (large_negative < std::numeric_limits<HistogramBase::Sample>::min()) {
220*635a8641SAndroid Build Coastguard Worker histogram->AddTimeMillisecondsGranularity(
221*635a8641SAndroid Build Coastguard Worker TimeDelta::FromMilliseconds(large_negative));
222*635a8641SAndroid Build Coastguard Worker ++add_count;
223*635a8641SAndroid Build Coastguard Worker large_negative /= 7;
224*635a8641SAndroid Build Coastguard Worker }
225*635a8641SAndroid Build Coastguard Worker samples = histogram->SnapshotSamples();
226*635a8641SAndroid Build Coastguard Worker // All of the reported values must have gone into the min overflow bucket.
227*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(add_count, samples->GetCount(0));
228*635a8641SAndroid Build Coastguard Worker }
229*635a8641SAndroid Build Coastguard Worker
TEST_F(HistogramBaseTest,AddTimeMicrosecondsGranularityOverflow)230*635a8641SAndroid Build Coastguard Worker TEST_F(HistogramBaseTest, AddTimeMicrosecondsGranularityOverflow) {
231*635a8641SAndroid Build Coastguard Worker // Nothing to test if we don't have a high resolution clock.
232*635a8641SAndroid Build Coastguard Worker if (!TimeTicks::IsHighResolution())
233*635a8641SAndroid Build Coastguard Worker return;
234*635a8641SAndroid Build Coastguard Worker
235*635a8641SAndroid Build Coastguard Worker const HistogramBase::Sample sample_max =
236*635a8641SAndroid Build Coastguard Worker std::numeric_limits<HistogramBase::Sample>::max() / 2;
237*635a8641SAndroid Build Coastguard Worker HistogramBase* histogram = LinearHistogram::FactoryGet(
238*635a8641SAndroid Build Coastguard Worker "TestAddTimeMicrosecondsGranularity1", 1, sample_max, 100, 0);
239*635a8641SAndroid Build Coastguard Worker int64_t large_positive = std::numeric_limits<int64_t>::max();
240*635a8641SAndroid Build Coastguard Worker // |add_count| is the number of large values that have been added to the
241*635a8641SAndroid Build Coastguard Worker // histogram. We consider a number to be 'large' if it cannot be represented
242*635a8641SAndroid Build Coastguard Worker // in a HistogramBase::Sample.
243*635a8641SAndroid Build Coastguard Worker int add_count = 0;
244*635a8641SAndroid Build Coastguard Worker while (large_positive > std::numeric_limits<HistogramBase::Sample>::max()) {
245*635a8641SAndroid Build Coastguard Worker // Add the TimeDelta corresponding to |large_positive| microseconds to the
246*635a8641SAndroid Build Coastguard Worker // histogram.
247*635a8641SAndroid Build Coastguard Worker histogram->AddTimeMicrosecondsGranularity(
248*635a8641SAndroid Build Coastguard Worker TimeDelta::FromMicroseconds(large_positive));
249*635a8641SAndroid Build Coastguard Worker ++add_count;
250*635a8641SAndroid Build Coastguard Worker // Reduce the value of |large_positive|. The choice of 7 here is
251*635a8641SAndroid Build Coastguard Worker // arbitrary.
252*635a8641SAndroid Build Coastguard Worker large_positive /= 7;
253*635a8641SAndroid Build Coastguard Worker }
254*635a8641SAndroid Build Coastguard Worker std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
255*635a8641SAndroid Build Coastguard Worker // All of the reported values must have gone into the max overflow bucket.
256*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(add_count, samples->GetCount(sample_max));
257*635a8641SAndroid Build Coastguard Worker
258*635a8641SAndroid Build Coastguard Worker // We now perform the analoguous operations, now with negative values with a
259*635a8641SAndroid Build Coastguard Worker // large absolute value.
260*635a8641SAndroid Build Coastguard Worker histogram = LinearHistogram::FactoryGet("TestAddTimeMicrosecondsGranularity2",
261*635a8641SAndroid Build Coastguard Worker 1, sample_max, 100, 0);
262*635a8641SAndroid Build Coastguard Worker int64_t large_negative = std::numeric_limits<int64_t>::min();
263*635a8641SAndroid Build Coastguard Worker add_count = 0;
264*635a8641SAndroid Build Coastguard Worker while (large_negative < std::numeric_limits<HistogramBase::Sample>::min()) {
265*635a8641SAndroid Build Coastguard Worker histogram->AddTimeMicrosecondsGranularity(
266*635a8641SAndroid Build Coastguard Worker TimeDelta::FromMicroseconds(large_negative));
267*635a8641SAndroid Build Coastguard Worker ++add_count;
268*635a8641SAndroid Build Coastguard Worker large_negative /= 7;
269*635a8641SAndroid Build Coastguard Worker }
270*635a8641SAndroid Build Coastguard Worker samples = histogram->SnapshotSamples();
271*635a8641SAndroid Build Coastguard Worker // All of the reported values must have gone into the min overflow bucket.
272*635a8641SAndroid Build Coastguard Worker EXPECT_EQ(add_count, samples->GetCount(0));
273*635a8641SAndroid Build Coastguard Worker }
274*635a8641SAndroid Build Coastguard Worker
275*635a8641SAndroid Build Coastguard Worker } // namespace base
276