Round Rate computations from RateTracker.
BUG=534221
R=asapersson@webrtc.org, pbos@webrtc.org, pthatcher@webrtc.org
Review URL: https://codereview.webrtc.org/1410533004 .
Cr-Commit-Position: refs/heads/master@{#10592}
diff --git a/webrtc/base/ratetracker.cc b/webrtc/base/ratetracker.cc
index 5cb4490..35521a8 100644
--- a/webrtc/base/ratetracker.cc
+++ b/webrtc/base/ratetracker.cc
@@ -73,8 +73,9 @@
size_t start_bucket = NextBucketIndex(current_bucket_ + buckets_to_skip);
// Only count a portion of the first bucket according to how much of the
// first bucket is within the current interval.
- size_t total_samples = sample_buckets_[start_bucket] *
- (bucket_milliseconds_ - milliseconds_to_skip) /
+ size_t total_samples = ((sample_buckets_[start_bucket] *
+ (bucket_milliseconds_ - milliseconds_to_skip)) +
+ (bucket_milliseconds_ >> 1)) /
bucket_milliseconds_;
// All other buckets in the interval are counted in their entirety.
for (size_t i = NextBucketIndex(start_bucket);
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index d34b05f..69dff94 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -1308,7 +1308,7 @@
}
size_t Connection::recv_bytes_second() {
- return recv_rate_tracker_.ComputeRate();
+ return round(recv_rate_tracker_.ComputeRate());
}
size_t Connection::recv_total_bytes() {
@@ -1316,7 +1316,7 @@
}
size_t Connection::sent_bytes_second() {
- return send_rate_tracker_.ComputeRate();
+ return round(send_rate_tracker_.ComputeRate());
}
size_t Connection::sent_total_bytes() {
diff --git a/webrtc/video/receive_statistics_proxy.cc b/webrtc/video/receive_statistics_proxy.cc
index eec2bc8..879a33d 100644
--- a/webrtc/video/receive_statistics_proxy.cc
+++ b/webrtc/video/receive_statistics_proxy.cc
@@ -44,9 +44,9 @@
int samples = static_cast<int>(render_fps_tracker_.TotalSampleCount());
if (samples > kMinRequiredSamples) {
RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.RenderFramesPerSecond",
- static_cast<int>(render_fps_tracker_.ComputeTotalRate()));
+ round(render_fps_tracker_.ComputeTotalRate()));
RTC_HISTOGRAM_COUNTS_100000("WebRTC.Video.RenderSqrtPixelsPerSecond",
- static_cast<int>(render_pixel_tracker_.ComputeTotalRate()));
+ round(render_pixel_tracker_.ComputeTotalRate()));
}
int width = render_width_counter_.Avg(kMinRequiredSamples);
int height = render_height_counter_.Avg(kMinRequiredSamples);
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc
index 916ffb3..57189f3 100644
--- a/webrtc/video/send_statistics_proxy.cc
+++ b/webrtc/video/send_statistics_proxy.cc
@@ -11,6 +11,7 @@
#include "webrtc/video/send_statistics_proxy.h"
#include <algorithm>
+#include <cmath>
#include <map>
#include "webrtc/base/checks.h"
@@ -70,11 +71,11 @@
void SendStatisticsProxy::UpdateHistograms() {
int input_fps =
- static_cast<int>(input_frame_rate_tracker_.ComputeTotalRate());
+ round(input_frame_rate_tracker_.ComputeTotalRate());
if (input_fps > 0)
RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.InputFramesPerSecond", input_fps);
int sent_fps =
- static_cast<int>(sent_frame_rate_tracker_.ComputeTotalRate());
+ round(sent_frame_rate_tracker_.ComputeTotalRate());
if (sent_fps > 0)
RTC_HISTOGRAM_COUNTS_100("WebRTC.Video.SentFramesPerSecond", sent_fps);
@@ -155,7 +156,7 @@
rtc::CritScope lock(&crit_);
PurgeOldStats();
stats_.input_frame_rate =
- static_cast<int>(input_frame_rate_tracker_.ComputeRate());
+ round(input_frame_rate_tracker_.ComputeRate());
return stats_;
}