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

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: Add GetAllSamples() and test. 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
Index: base/test/histogram_tester.cc
diff --git a/base/test/histogram_tester.cc b/base/test/histogram_tester.cc
index ea738b0557b6e864a7e68c7d840c079d5c5967d8..7529af1d057b64aada5ece31d03c4d5082738321 100644
--- a/base/test/histogram_tester.cc
+++ b/base/test/histogram_tester.cc
@@ -73,6 +73,20 @@ void HistogramTester::ExpectTotalCount(const std::string& name,
}
}
+std::vector<std::pair<HistogramBase::Sample, HistogramBase::Count>>
+HistogramTester::GetAllSamples(const std::string& name) {
+ std::vector<std::pair<HistogramBase::Sample, HistogramBase::Count>> 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(std::make_pair(sample, count));
+ }
+ return samples;
+}
+
scoped_ptr<HistogramSamples> HistogramTester::GetHistogramSamplesSinceCreation(
const std::string& histogram_name) {
HistogramBase* histogram = StatisticsRecorder::FindHistogram(histogram_name);

Powered by Google App Engine
This is Rietveld 408576698