| 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
| 9 #include "base/metrics/sample_map.h" | 9 #include "base/metrics/sample_map.h" |
| 10 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // generated a histogram or not (see http://crbug.com/473689). To provide a | 120 // generated a histogram or not (see http://crbug.com/473689). To provide a |
| 121 // response which is independent of the previously run tests, this method | 121 // response which is independent of the previously run tests, this method |
| 122 // creates empty samples in the absence of the histogram, rather than | 122 // creates empty samples in the absence of the histogram, rather than |
| 123 // returning null. | 123 // returning null. |
| 124 if (!histogram) | 124 if (!histogram) |
| 125 return scoped_ptr<HistogramSamples>(new SampleMap); | 125 return scoped_ptr<HistogramSamples>(new SampleMap); |
| 126 scoped_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples()); | 126 scoped_ptr<HistogramSamples> named_samples(histogram->SnapshotSamples()); |
| 127 auto original_samples_it = histograms_snapshot_.find(histogram_name); | 127 auto original_samples_it = histograms_snapshot_.find(histogram_name); |
| 128 if (original_samples_it != histograms_snapshot_.end()) | 128 if (original_samples_it != histograms_snapshot_.end()) |
| 129 named_samples->Subtract(*original_samples_it->second); | 129 named_samples->Subtract(*original_samples_it->second); |
| 130 return named_samples.Pass(); | 130 return named_samples; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void HistogramTester::CheckBucketCount( | 133 void HistogramTester::CheckBucketCount( |
| 134 const std::string& name, | 134 const std::string& name, |
| 135 base::HistogramBase::Sample sample, | 135 base::HistogramBase::Sample sample, |
| 136 base::HistogramBase::Count expected_count, | 136 base::HistogramBase::Count expected_count, |
| 137 const base::HistogramSamples& samples) const { | 137 const base::HistogramSamples& samples) const { |
| 138 int actual_count = samples.GetCount(sample); | 138 int actual_count = samples.GetCount(sample); |
| 139 std::map<std::string, HistogramSamples*>::const_iterator histogram_data; | 139 std::map<std::string, HistogramSamples*>::const_iterator histogram_data; |
| 140 histogram_data = histograms_snapshot_.find(name); | 140 histogram_data = histograms_snapshot_.find(name); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 166 | 166 |
| 167 bool Bucket::operator==(const Bucket& other) const { | 167 bool Bucket::operator==(const Bucket& other) const { |
| 168 return min == other.min && count == other.count; | 168 return min == other.min && count == other.count; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void PrintTo(const Bucket& bucket, std::ostream* os) { | 171 void PrintTo(const Bucket& bucket, std::ostream* os) { |
| 172 *os << "Bucket " << bucket.min << ": " << bucket.count; | 172 *os << "Bucket " << bucket.min << ": " << bucket.count; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace base | 175 } // namespace base |
| OLD | NEW |