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

Unified Diff: webrtc/video/send_statistics_proxy.cc

Issue 2786593003: Add histogram stats for number of cpu/quality adapt changes per minute for sent video streams: (Closed)
Patch Set: address comments Created 3 years, 8 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
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/send_statistics_proxy.cc
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc
index 3b9134b08e4d5308c3ebc8a33e20ae604fde57ba..afaeed904d4d7e273ffe264be118f0e27ca64ff9 100644
--- a/webrtc/video/send_statistics_proxy.cc
+++ b/webrtc/video/send_statistics_proxy.cc
@@ -293,6 +293,24 @@ void SendStatisticsProxy::UmaSamplesContainer::UpdateHistograms(
}
}
+ quality_scaling_timer_.Stop(clock_->TimeInMilliseconds());
+ int64_t elapsed_sec = quality_scaling_timer_.total_ms / 1000;
+ if (elapsed_sec >= metrics::kMinRunTimeInSeconds) {
+ int quality_changes = current_stats.number_of_quality_adapt_changes -
+ start_stats_.number_of_quality_adapt_changes;
+ RTC_HISTOGRAMS_COUNTS_100(kIndex,
+ uma_prefix_ + "AdaptChangesPerMinute.Quality",
+ quality_changes * 60 / elapsed_sec);
+ }
+ cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds());
+ elapsed_sec = cpu_scaling_timer_.total_ms / 1000;
+ if (elapsed_sec >= metrics::kMinRunTimeInSeconds) {
+ int cpu_changes = current_stats.number_of_cpu_adapt_changes -
+ start_stats_.number_of_cpu_adapt_changes;
+ RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "AdaptChangesPerMinute.Cpu",
+ cpu_changes * 60 / elapsed_sec);
+ }
+
if (first_rtcp_stats_time_ms_ != -1) {
int64_t elapsed_sec =
(clock_->TimeInMilliseconds() - first_rtcp_stats_time_ms_) / 1000;
@@ -684,15 +702,29 @@ void SendStatisticsProxy::OnIncomingFrame(int width, int height) {
"ssrc", rtp_config_.ssrcs[0]);
}
-void SendStatisticsProxy::SetCpuScalingStats(bool cpu_restricted_resolution) {
+void SendStatisticsProxy::SetCpuScalingStats(int num_cpu_downscales) {
rtc::CritScope lock(&crit_);
- stats_.cpu_limited_resolution = cpu_restricted_resolution;
+ stats_.cpu_limited_resolution = num_cpu_downscales > 0;
+
+ if (num_cpu_downscales >= 0) {
+ // Scaling enabled.
+ uma_container_->cpu_scaling_timer_.Start(clock_->TimeInMilliseconds());
+ } else {
+ uma_container_->cpu_scaling_timer_.Stop(clock_->TimeInMilliseconds());
+ }
}
void SendStatisticsProxy::SetQualityScalingStats(int num_quality_downscales) {
rtc::CritScope lock(&crit_);
quality_downscales_ = num_quality_downscales;
stats_.bw_limited_resolution = quality_downscales_ > 0;
+
+ if (num_quality_downscales >= 0) {
+ // Scaling enabled.
+ uma_container_->quality_scaling_timer_.Start(clock_->TimeInMilliseconds());
+ } else {
+ uma_container_->quality_scaling_timer_.Stop(clock_->TimeInMilliseconds());
+ }
}
void SendStatisticsProxy::OnCpuRestrictedResolutionChanged(
@@ -700,7 +732,7 @@ void SendStatisticsProxy::OnCpuRestrictedResolutionChanged(
rtc::CritScope lock(&crit_);
stats_.cpu_limited_resolution = cpu_restricted_resolution;
++stats_.number_of_cpu_adapt_changes;
- TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.AdaptationChanges");
+ TRACE_EVENT_INSTANT0("webrtc_stats", "WebRTC.Video.CpuAdaptationChanges");
}
void SendStatisticsProxy::OnQualityRestrictedResolutionChanged(
@@ -761,8 +793,12 @@ void SendStatisticsProxy::DataCountersUpdated(
}
stats->rtp_stats = counters;
- if (uma_container_->first_rtp_stats_time_ms_ == -1)
- uma_container_->first_rtp_stats_time_ms_ = clock_->TimeInMilliseconds();
+ if (uma_container_->first_rtp_stats_time_ms_ == -1) {
+ int64_t now_ms = clock_->TimeInMilliseconds();
+ uma_container_->first_rtp_stats_time_ms_ = now_ms;
+ uma_container_->cpu_scaling_timer_.Restart(now_ms);
+ uma_container_->quality_scaling_timer_.Restart(now_ms);
+ }
uma_container_->total_byte_counter_.Set(counters.transmitted.TotalBytes(),
ssrc);
@@ -818,6 +854,24 @@ void SendStatisticsProxy::SendSideDelayUpdated(int avg_delay_ms,
uma_container_->max_delay_counter_.Add(max_delay_ms);
}
+void SendStatisticsProxy::StatsTimer::Start(int64_t now_ms) {
+ if (start_ms == -1)
+ start_ms = now_ms;
+}
+
+void SendStatisticsProxy::StatsTimer::Stop(int64_t now_ms) {
+ if (start_ms != -1) {
+ total_ms += now_ms - start_ms;
+ start_ms = -1;
+ }
+}
+
+void SendStatisticsProxy::StatsTimer::Restart(int64_t now_ms) {
+ total_ms = 0;
+ if (start_ms != -1)
+ start_ms = now_ms;
+}
+
void SendStatisticsProxy::SampleCounter::Add(int sample) {
sum += sample;
++num_samples;
« no previous file with comments | « webrtc/video/send_statistics_proxy.h ('k') | webrtc/video/send_statistics_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698