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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc

Issue 1253473004: BWE Simulation Framework: Standard plot logging (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed [2] Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 uint32_t PacketProcessor::packets_per_second() const { 244 uint32_t PacketProcessor::packets_per_second() const {
245 return rate_counter_.packets_per_second(); 245 return rate_counter_.packets_per_second();
246 } 246 }
247 247
248 uint32_t PacketProcessor::bits_per_second() const { 248 uint32_t PacketProcessor::bits_per_second() const {
249 return rate_counter_.bits_per_second(); 249 return rate_counter_.bits_per_second();
250 } 250 }
251 251
252 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, 252 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener,
253 int flow_id, 253 int flow_id,
254 const char* name) 254 const char* name,
255 const std::string& plot_name)
255 : PacketProcessor(listener, flow_id, kRegular), 256 : PacketProcessor(listener, flow_id, kRegular),
256 packets_per_second_stats_(), 257 packets_per_second_stats_(),
257 kbps_stats_(), 258 kbps_stats_(),
258 name_(), 259 start_plotting_time_ms_(0),
259 start_plotting_time_ms_(0) { 260 plot_name_(plot_name) {
260 std::stringstream ss; 261 std::stringstream ss;
261 ss << name << "_" << flow_id; 262 ss << name << "_" << flow_id;
262 name_ = ss.str(); 263 name_ = ss.str();
263 } 264 }
264 265
265 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, 266 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener,
266 const FlowIds& flow_ids, 267 const FlowIds& flow_ids,
267 const char* name) 268 const char* name,
269 const std::string& plot_name)
268 : PacketProcessor(listener, flow_ids, kRegular), 270 : PacketProcessor(listener, flow_ids, kRegular),
269 packets_per_second_stats_(), 271 packets_per_second_stats_(),
270 kbps_stats_(), 272 kbps_stats_(),
271 name_(), 273 start_plotting_time_ms_(0),
272 start_plotting_time_ms_(0) { 274 plot_name_(plot_name) {
273 std::stringstream ss; 275 std::stringstream ss;
274 ss << name << "_"; 276 ss << name;
277 char delimiter = '_';
275 for (int flow_id : flow_ids) { 278 for (int flow_id : flow_ids) {
276 ss << flow_id << ","; 279 ss << delimiter << flow_id;
280 delimiter = ',';
277 } 281 }
278 name_ = ss.str(); 282 name_ = ss.str();
279 } 283 }
280 284
281 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, 285 RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener,
282 const FlowIds& flow_ids, 286 const FlowIds& flow_ids,
283 const char* name, 287 const char* name,
284 int64_t start_plotting_time_ms) 288 int64_t start_plotting_time_ms,
285 : RateCounterFilter(listener, flow_ids, name) { 289 const std::string& plot_name)
290 : RateCounterFilter(listener, flow_ids, name, plot_name) {
286 start_plotting_time_ms_ = start_plotting_time_ms; 291 start_plotting_time_ms_ = start_plotting_time_ms;
287 } 292 }
288 293
289 RateCounterFilter::~RateCounterFilter() { 294 RateCounterFilter::~RateCounterFilter() {
290 LogStats(); 295 LogStats();
291 } 296 }
292 297
293 298
294 void RateCounterFilter::LogStats() { 299 void RateCounterFilter::LogStats() {
295 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter"); 300 BWE_TEST_LOGGING_CONTEXT("RateCounterFilter");
296 packets_per_second_stats_.Log("pps"); 301 packets_per_second_stats_.Log("pps");
297 kbps_stats_.Log("kbps"); 302 kbps_stats_.Log("kbps");
298 } 303 }
299 304
300 Stats<double> RateCounterFilter::GetBitrateStats() const { 305 Stats<double> RateCounterFilter::GetBitrateStats() const {
301 return kbps_stats_; 306 return kbps_stats_;
302 } 307 }
303 308
304 void RateCounterFilter::Plot(int64_t timestamp_ms) { 309 void RateCounterFilter::Plot(int64_t timestamp_ms) {
305 uint32_t plot_kbps = 0; 310 uint32_t plot_kbps = 0;
306 if (timestamp_ms >= start_plotting_time_ms_) { 311 if (timestamp_ms >= start_plotting_time_ms_) {
307 plot_kbps = rate_counter_.bits_per_second() / 1000.0; 312 plot_kbps = rate_counter_.bits_per_second() / 1000.0;
308 } 313 }
309 BWE_TEST_LOGGING_CONTEXT(name_.c_str()); 314 BWE_TEST_LOGGING_CONTEXT(name_.c_str());
310 BWE_TEST_LOGGING_PLOT(0, "Throughput_#1", timestamp_ms, plot_kbps); 315 if (plot_name_.empty()) {
316 BWE_TEST_LOGGING_PLOT(0, "Throughput_kbps#1", timestamp_ms, plot_kbps);
317 } else {
318 BWE_TEST_LOGGING_PLOT_WITH_NAME(0, "Throughput_kbps#1", timestamp_ms,
319 plot_kbps, plot_name_);
320 }
321
311 RTC_UNUSED(plot_kbps); 322 RTC_UNUSED(plot_kbps);
312 } 323 }
313 324
314 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { 325 void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) {
315 assert(in_out); 326 assert(in_out);
316 for (const Packet* packet : *in_out) { 327 for (const Packet* packet : *in_out) {
317 rate_counter_.UpdateRates(packet->send_time_us(), 328 rate_counter_.UpdateRates(packet->send_time_us(),
318 static_cast<int>(packet->payload_size())); 329 static_cast<int>(packet->payload_size()));
319 } 330 }
320 packets_per_second_stats_.Push(rate_counter_.packets_per_second()); 331 packets_per_second_stats_.Push(rate_counter_.packets_per_second());
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size, 842 uint32_t PeriodicKeyFrameSource::NextPacketSize(uint32_t frame_size,
832 uint32_t remaining_payload) { 843 uint32_t remaining_payload) {
833 uint32_t fragments = 844 uint32_t fragments =
834 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes; 845 (frame_size + (kMaxPayloadSizeBytes - 1)) / kMaxPayloadSizeBytes;
835 uint32_t avg_size = (frame_size + fragments - 1) / fragments; 846 uint32_t avg_size = (frame_size + fragments - 1) / fragments;
836 return std::min(avg_size, remaining_payload); 847 return std::min(avg_size, remaining_payload);
837 } 848 }
838 } // namespace bwe 849 } // namespace bwe
839 } // namespace testing 850 } // namespace testing
840 } // namespace webrtc 851 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698