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" |
11 #include "base/metrics/metrics_hashes.h" | 11 #include "base/metrics/metrics_hashes.h" |
12 #include "base/metrics/sample_map.h" | 12 #include "base/metrics/sample_map.h" |
13 #include "base/metrics/statistics_recorder.h" | 13 #include "base/metrics/statistics_recorder.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 | 18 |
19 HistogramTester::HistogramTester() { | 19 HistogramTester::HistogramTester() { |
20 StatisticsRecorder::Initialize(); // Safe to call multiple times. | 20 StatisticsRecorder::Initialize(); // Safe to call multiple times. |
21 | 21 |
22 // Record any histogram data that exists when the object is created so it can | 22 // Record any histogram data that exists when the object is created so it can |
23 // be subtracted later. | 23 // be subtracted later. |
24 StatisticsRecorder::Histograms histograms; | 24 StatisticsRecorder::Histograms histograms; |
25 StatisticsRecorder::GetSnapshot(std::string(), &histograms); | 25 StatisticsRecorder::GetSnapshot(std::string(), &histograms); |
26 for (const auto& histogram : histograms) { | 26 for (const auto* histogram : histograms) { |
27 histograms_snapshot_[histogram->histogram_name()] = | 27 histograms_snapshot_[histogram->histogram_name()] = |
28 histogram->SnapshotSamples(); | 28 histogram->SnapshotSamples(); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 HistogramTester::~HistogramTester() { | 32 HistogramTester::~HistogramTester() { |
33 } | 33 } |
34 | 34 |
35 void HistogramTester::ExpectUniqueSample( | 35 void HistogramTester::ExpectUniqueSample( |
36 const std::string& name, | 36 const std::string& name, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 bool Bucket::operator==(const Bucket& other) const { | 176 bool Bucket::operator==(const Bucket& other) const { |
177 return min == other.min && count == other.count; | 177 return min == other.min && count == other.count; |
178 } | 178 } |
179 | 179 |
180 void PrintTo(const Bucket& bucket, std::ostream* os) { | 180 void PrintTo(const Bucket& bucket, std::ostream* os) { |
181 *os << "Bucket " << bucket.min << ": " << bucket.count; | 181 *os << "Bucket " << bucket.min << ": " << bucket.count; |
182 } | 182 } |
183 | 183 |
184 } // namespace base | 184 } // namespace base |
OLD | NEW |