OLD | NEW |
1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 1 // Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the LICENSE file in the root of the source | 4 // that can be found in the LICENSE file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 // | 8 // |
9 | 9 |
10 #include "webrtc/system_wrappers/include/metrics_default.h" | 10 #include "webrtc/system_wrappers/include/metrics_default.h" |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 const std::string& name, | 237 const std::string& name, |
238 int sample) { | 238 int sample) { |
239 if (!histogram_pointer) | 239 if (!histogram_pointer) |
240 return; | 240 return; |
241 | 241 |
242 RtcHistogram* ptr = reinterpret_cast<RtcHistogram*>(histogram_pointer); | 242 RtcHistogram* ptr = reinterpret_cast<RtcHistogram*>(histogram_pointer); |
243 RTC_DCHECK_EQ(name, ptr->name()) << "The name should not vary."; | 243 RTC_DCHECK_EQ(name, ptr->name()) << "The name should not vary."; |
244 ptr->Add(sample); | 244 ptr->Add(sample); |
245 } | 245 } |
246 | 246 |
| 247 // Fast path. Adds |sample| to cached |histogram_pointer|. |
| 248 void HistogramAdd(Histogram* histogram_pointer, int sample) { |
| 249 if (!histogram_pointer) |
| 250 return; |
| 251 |
| 252 RtcHistogram* ptr = reinterpret_cast<RtcHistogram*>(histogram_pointer); |
| 253 ptr->Add(sample); |
| 254 } |
| 255 |
247 SampleInfo::SampleInfo(const std::string& name, | 256 SampleInfo::SampleInfo(const std::string& name, |
248 int min, | 257 int min, |
249 int max, | 258 int max, |
250 size_t bucket_count) | 259 size_t bucket_count) |
251 : name(name), min(min), max(max), bucket_count(bucket_count) {} | 260 : name(name), min(min), max(max), bucket_count(bucket_count) {} |
252 | 261 |
253 SampleInfo::~SampleInfo() {} | 262 SampleInfo::~SampleInfo() {} |
254 | 263 |
255 // Implementation of global functions in metrics_default.h. | 264 // Implementation of global functions in metrics_default.h. |
256 void Enable() { | 265 void Enable() { |
(...skipping 28 matching lines...) Expand all Loading... |
285 return map ? map->NumSamples(name) : 0; | 294 return map ? map->NumSamples(name) : 0; |
286 } | 295 } |
287 | 296 |
288 int MinSample(const std::string& name) { | 297 int MinSample(const std::string& name) { |
289 RtcHistogramMap* map = GetMap(); | 298 RtcHistogramMap* map = GetMap(); |
290 return map ? map->MinSample(name) : -1; | 299 return map ? map->MinSample(name) : -1; |
291 } | 300 } |
292 | 301 |
293 } // namespace metrics | 302 } // namespace metrics |
294 } // namespace webrtc | 303 } // namespace webrtc |
OLD | NEW |