OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 metrics::GetAndReset(&histograms); | 127 metrics::GetAndReset(&histograms); |
128 EXPECT_EQ(2u, histograms.size()); | 128 EXPECT_EQ(2u, histograms.size()); |
129 EXPECT_EQ(0, metrics::NumSamples("Histogram1")); | 129 EXPECT_EQ(0, metrics::NumSamples("Histogram1")); |
130 EXPECT_EQ(0, metrics::NumSamples("Histogram2")); | 130 EXPECT_EQ(0, metrics::NumSamples("Histogram2")); |
131 | 131 |
132 EXPECT_EQ(3, NumSamples("Histogram1", histograms)); | 132 EXPECT_EQ(3, NumSamples("Histogram1", histograms)); |
133 EXPECT_EQ(1, NumSamples("Histogram2", histograms)); | 133 EXPECT_EQ(1, NumSamples("Histogram2", histograms)); |
134 EXPECT_EQ(1, NumEvents("Histogram1", 4, histograms)); | 134 EXPECT_EQ(1, NumEvents("Histogram1", 4, histograms)); |
135 EXPECT_EQ(2, NumEvents("Histogram1", 5, histograms)); | 135 EXPECT_EQ(2, NumEvents("Histogram1", 5, histograms)); |
136 EXPECT_EQ(1, NumEvents("Histogram2", 10, histograms)); | 136 EXPECT_EQ(1, NumEvents("Histogram2", 10, histograms)); |
| 137 |
| 138 // Add samples after reset. |
| 139 metrics::GetAndReset(&histograms); |
| 140 EXPECT_EQ(0u, histograms.size()); |
| 141 RTC_HISTOGRAM_PERCENTAGE("Histogram1", 50); |
| 142 RTC_HISTOGRAM_PERCENTAGE("Histogram2", 8); |
| 143 EXPECT_EQ(1, metrics::NumSamples("Histogram1")); |
| 144 EXPECT_EQ(1, metrics::NumSamples("Histogram2")); |
| 145 EXPECT_EQ(1, metrics::NumEvents("Histogram1", 50)); |
| 146 EXPECT_EQ(1, metrics::NumEvents("Histogram2", 8)); |
137 } | 147 } |
138 | 148 |
139 TEST_F(MetricsDefaultTest, TestMinMaxBucket) { | 149 TEST_F(MetricsDefaultTest, TestMinMaxBucket) { |
140 const std::string kName = "MinMaxCounts100"; | 150 const std::string kName = "MinMaxCounts100"; |
141 RTC_HISTOGRAM_COUNTS_100(kName, 4); | 151 RTC_HISTOGRAM_COUNTS_100(kName, 4); |
142 | 152 |
143 std::map<std::string, std::unique_ptr<metrics::SampleInfo>> histograms; | 153 std::map<std::string, std::unique_ptr<metrics::SampleInfo>> histograms; |
144 metrics::GetAndReset(&histograms); | 154 metrics::GetAndReset(&histograms); |
145 EXPECT_EQ(1u, histograms.size()); | 155 EXPECT_EQ(1u, histograms.size()); |
146 EXPECT_EQ(kName, histograms.begin()->second->name); | 156 EXPECT_EQ(kName, histograms.begin()->second->name); |
147 EXPECT_EQ(1, histograms.begin()->second->min); | 157 EXPECT_EQ(1, histograms.begin()->second->min); |
148 EXPECT_EQ(100, histograms.begin()->second->max); | 158 EXPECT_EQ(100, histograms.begin()->second->max); |
149 EXPECT_EQ(50u, histograms.begin()->second->bucket_count); | 159 EXPECT_EQ(50u, histograms.begin()->second->bucket_count); |
150 EXPECT_EQ(1u, histograms.begin()->second->samples.size()); | 160 EXPECT_EQ(1u, histograms.begin()->second->samples.size()); |
151 } | 161 } |
152 | 162 |
153 } // namespace webrtc | 163 } // namespace webrtc |
OLD | NEW |