Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc

Issue 2654473002: Remove static locals from histograms. (Closed)
Patch Set: use another HistogramBase constructor for enumerations Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
index ad8a6f9e77140d7a7af703c08df4d746be51c569..0e6cddf8e4711326ca2017b7fea4559b667e2061 100644
--- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
+++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
@@ -34,23 +34,22 @@ const int64_t kRtcEventLogPeriodMs = 5000;
const int64_t kFeedbackIntervalMs = 1500;
const int64_t kFeedbackTimeoutIntervals = 3;
const int64_t kTimeoutIntervalMs = 1000;
-
-struct UmaRampUpMetric {
- const char* metric_name;
- int bitrate_kbps;
-};
-
-const UmaRampUpMetric kUmaRampupMetrics[] = {
- {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500},
- {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000},
- {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}};
-const size_t kNumUmaRampupMetrics =
- sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]);
-
} // namespace
SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
- : lost_packets_since_last_loss_update_Q8_(0),
+ : rampup_histograms_{
+ {rtc::Histogram("WebRTC.BWE.RampUpTimeTo500kbpsInMs", 100000), 500},
+ {rtc::Histogram("WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 100000), 1000},
+ {rtc::Histogram("WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 100000), 2000},
+ },
+ initially_lost_packets_histogram_(
+ rtc::Histogram("WebRTC.BWE.InitiallyLostPackets", 0, 100)),
+ initial_rtt_histogram_(rtc::Histogram("WebRTC.BWE.InitialRtt", 0, 2000)),
+ initial_bwe_histogram_(
+ rtc::Histogram("WebRTC.BWE.InitialBandwidthEstimate", 0, 2000)),
+ initial_vs_converged_diff_histogram_(
+ rtc::Histogram("WebRTC.BWE.InitialVsConvergedDiff", 0, 2000)),
+ lost_packets_since_last_loss_update_Q8_(0),
expected_packets_since_last_loss_update_(0),
bitrate_(0),
min_bitrate_configured_(congestion_controller::GetMinBitrateBps()),
@@ -70,7 +69,9 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
initially_lost_packets_(0),
bitrate_at_2_seconds_kbps_(0),
uma_update_state_(kNoUpdate),
- rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
+ rampup_uma_stats_updated_(
+ sizeof(rampup_histograms_) / sizeof(*rampup_histograms_),
+ false),
event_log_(event_log),
last_rtc_event_log_ms_(-1),
in_timeout_experiment_(webrtc::field_trial::FindFullName(
@@ -175,11 +176,10 @@ void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms,
int64_t rtt,
int lost_packets) {
int bitrate_kbps = static_cast<int>((bitrate_ + 500) / 1000);
- for (size_t i = 0; i < kNumUmaRampupMetrics; ++i) {
+ for (size_t i = 0; i < rampup_uma_stats_updated_.size(); ++i) {
if (!rampup_uma_stats_updated_[i] &&
- bitrate_kbps >= kUmaRampupMetrics[i].bitrate_kbps) {
- RTC_HISTOGRAMS_COUNTS_100000(i, kUmaRampupMetrics[i].metric_name,
- now_ms - first_report_time_ms_);
+ bitrate_kbps >= rampup_histograms_[i].bitrate_kbps) {
+ rampup_histograms_[i].histogram.AddSample(now_ms - first_report_time_ms_);
rampup_uma_stats_updated_[i] = true;
}
}
@@ -188,19 +188,15 @@ void SendSideBandwidthEstimation::UpdateUmaStats(int64_t now_ms,
} else if (uma_update_state_ == kNoUpdate) {
uma_update_state_ = kFirstDone;
bitrate_at_2_seconds_kbps_ = bitrate_kbps;
- RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitiallyLostPackets",
- initially_lost_packets_, 0, 100, 50);
- RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialRtt", static_cast<int>(rtt), 0,
- 2000, 50);
- RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialBandwidthEstimate",
- bitrate_at_2_seconds_kbps_, 0, 2000, 50);
+ initially_lost_packets_histogram_.AddSample(initially_lost_packets_);
+ initial_rtt_histogram_.AddSample(static_cast<int>(rtt));
+ initial_bwe_histogram_.AddSample(bitrate_at_2_seconds_kbps_);
} else if (uma_update_state_ == kFirstDone &&
now_ms - first_report_time_ms_ >= kBweConverganceTimeMs) {
uma_update_state_ = kDone;
int bitrate_diff_kbps =
std::max(bitrate_at_2_seconds_kbps_ - bitrate_kbps, 0);
- RTC_HISTOGRAM_COUNTS("WebRTC.BWE.InitialVsConvergedDiff", bitrate_diff_kbps,
- 0, 2000, 50);
+ initial_vs_converged_diff_histogram_.AddSample(bitrate_diff_kbps);
}
}
« no previous file with comments | « webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h ('k') | webrtc/system_wrappers/source/metrics_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698