Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/test/histogram_tester.h" | 5 #include "base/test/histogram_tester.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 if (histogram) { | 71 if (histogram) { |
| 72 std::unique_ptr<base::HistogramSamples> samples = | 72 std::unique_ptr<base::HistogramSamples> samples = |
| 73 histogram->SnapshotSamples(); | 73 histogram->SnapshotSamples(); |
| 74 CheckTotalCount(name, count, *samples); | 74 CheckTotalCount(name, count, *samples); |
| 75 } else { | 75 } else { |
| 76 // No histogram means there were zero samples. | 76 // No histogram means there were zero samples. |
| 77 EXPECT_EQ(count, 0) << "Histogram \"" << name << "\" does not exist."; | 77 EXPECT_EQ(count, 0) << "Histogram \"" << name << "\" does not exist."; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 void HistogramTester::ExpectTimeBucketCount( | |
| 82 const std::string& name, const base::TimeDelta& sample, | |
|
Alexei Svitkine (slow)
2016/11/12 00:51:14
Nit: 1 param per line.
nikunjb
2016/11/12 01:35:15
Done.
| |
| 83 base::HistogramBase::Count count) const { | |
| 84 ExpectBucketCount(name, sample.InMilliseconds(), count); | |
| 85 } | |
| 86 | |
| 81 std::vector<Bucket> HistogramTester::GetAllSamples( | 87 std::vector<Bucket> HistogramTester::GetAllSamples( |
| 82 const std::string& name) const { | 88 const std::string& name) const { |
| 83 std::vector<Bucket> samples; | 89 std::vector<Bucket> samples; |
| 84 std::unique_ptr<HistogramSamples> snapshot = | 90 std::unique_ptr<HistogramSamples> snapshot = |
| 85 GetHistogramSamplesSinceCreation(name); | 91 GetHistogramSamplesSinceCreation(name); |
| 86 if (snapshot) { | 92 if (snapshot) { |
| 87 for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) { | 93 for (auto it = snapshot->Iterator(); !it->Done(); it->Next()) { |
| 88 HistogramBase::Sample sample; | 94 HistogramBase::Sample sample; |
| 89 HistogramBase::Count count; | 95 HistogramBase::Count count; |
| 90 it->Get(&sample, nullptr, &count); | 96 it->Get(&sample, nullptr, &count); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 178 |
| 173 bool Bucket::operator==(const Bucket& other) const { | 179 bool Bucket::operator==(const Bucket& other) const { |
| 174 return min == other.min && count == other.count; | 180 return min == other.min && count == other.count; |
| 175 } | 181 } |
| 176 | 182 |
| 177 void PrintTo(const Bucket& bucket, std::ostream* os) { | 183 void PrintTo(const Bucket& bucket, std::ostream* os) { |
| 178 *os << "Bucket " << bucket.min << ": " << bucket.count; | 184 *os << "Bucket " << bucket.min << ": " << bucket.count; |
| 179 } | 185 } |
| 180 | 186 |
| 181 } // namespace base | 187 } // namespace base |
| OLD | NEW |