Chromium Code Reviews| Index: base/test/histogram_tester.cc |
| diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc |
| index ea738b0557b6e864a7e68c7d840c079d5c5967d8..2e89a2cc3501b9ff43c8129a75c994d8b7a6a640 100644 |
| --- a/base/test/histogram_tester.cc |
| +++ b/base/test/histogram_tester.cc |
| @@ -73,6 +73,19 @@ void HistogramTester::ExpectTotalCount(const std::string& name, |
| } |
| } |
| +std::vector<Bucket> HistogramTester::GetAllSamples(const std::string& name) { |
| + std::vector<Bucket> samples; |
| + scoped_ptr<HistogramSamples> snapshot = |
| + GetHistogramSamplesSinceCreation(name); |
| + for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) { |
| + HistogramBase::Sample sample; |
| + HistogramBase::Count count; |
| + it->Get(&sample, nullptr, &count); |
| + samples.push_back(Bucket(sample, count)); |
| + } |
| + return samples; |
| +} |
| + |
| scoped_ptr<HistogramSamples> HistogramTester::GetHistogramSamplesSinceCreation( |
| const std::string& histogram_name) { |
| HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name); |
| @@ -120,4 +133,13 @@ void HistogramTester::CheckTotalCount( |
| << expected_count << "). It has (" << actual_count << ")."; |
| } |
| +bool Bucket::operator==(const Bucket& other) const { |
| + return min_ == other.min_ && count_ == other.count_; |
| +} |
| + |
| +void PrintTo(const Bucket& bucket, std::ostream* os) { |
| + *os << bucket.count_ << (bucket.count_ == 1 ? " sample " : " samples ") |
| + << "in bucket " << bucket.min_; |
|
Ilya Sherman
2015/06/27 07:25:19
WDYT of something shorter, like the following?
twifkak
2015/06/29 21:52:29
That doesn't seem to be any clearer than a pair. H
Ilya Sherman
2015/06/29 22:05:34
Yeah, I think that's a good compromise between cla
|
| +} |
| + |
| } // namespace base |