Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2162)

Unified Diff: base/test/histogram_tester.cc

Issue 1177263004: Add HistogramTester::GetAllSamples. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove member variable const qualifications, for std::vector. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/histogram_tester.h ('k') | base/test/histogram_tester_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/histogram_tester.cc
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index ea738b0557b6e864a7e68c7d840c079d5c5967d8..0eba3a9a27938e6ef7ecd7872f466159284a5717 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,12 @@ 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 " << bucket.min << ": " << bucket.count;
+}
+
} // namespace base
« no previous file with comments | « base/test/histogram_tester.h ('k') | base/test/histogram_tester_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698