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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/metric_recorder.h

Issue 1202253003: More Simulation Framework features (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Using rtc::scoped_ptr on nada_unittest.cc Created 5 years, 5 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
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_METRIC_RECORDER_H_
12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_METRIC_RECORDER_H_
13
14 #include <set>
15 #include <string>
16 #include <vector>
17
18 #include "webrtc/base/common.h"
19 #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
20
21 namespace webrtc {
22 namespace testing {
23 namespace bwe {
24
25 class LinkShare {
26 public:
27 explicit LinkShare(ChokeFilter* choke_filter);
28
29 void PauseFlow(int flow_id); // Increases available capacity per flow.
30 void ResumeFlow(int flow_id); // Decreases available capacity per flow.
31
32 uint32_t TotalAvailableKbps();
33 // If the given flow is paused, its output is zero.
34 uint32_t AvailablePerFlowKbps(int flow_id);
35
36 private:
37 ChokeFilter* choke_filter_;
38 std::set<int> running_flows_;
39 };
40
41 struct PlotInformation {
42 PlotInformation()
43 : prefix(),
44 last_plot_ms(0),
45 time_ms(0),
46 value(0.0),
47 plot_interval_ms(0) {}
48 template <typename T>
49 void Update(int64_t now_ms, T new_value) {
50 time_ms = now_ms;
51 value = static_cast<double>(new_value);
52 }
53 std::string prefix;
54 bool plot;
55 int64_t last_plot_ms;
56 int64_t time_ms;
57 double value;
58 int64_t plot_interval_ms;
59 };
60
61 class MetricRecorder {
62 public:
63 MetricRecorder(const std::string algorithm_name,
64 int flow_id,
65 PacketSender* packet_sender,
66 LinkShare* link_share);
67
68 void SetPlotInformation(const std::vector<std::string>& prefixes);
69
70 template <typename T>
71 void PlotLine(int windows_id,
72 const std::string& prefix,
73 int64_t time_ms,
74 T y);
75
76 void PlotDynamics(int metric);
77 void PlotAllDynamics();
78
79 void UpdateTime(int64_t time_ms);
80 void UpdateThroughput(int64_t bitrate_kbps, size_t payload_size);
81 void UpdateDelay(int64_t delay_ms);
82 void UpdateLoss(float loss_ratio);
83 void UpdateObjective();
84
85 void PlotThroughputHistogram(const std::string& title,
86 const std::string& bwe_name,
87 int num_flows,
88 int64_t extra_offset_ms,
89 const std::string optimum_id);
90
91 void PlotThroughputHistogram(const std::string& title,
92 const std::string& bwe_name,
93 int num_flows,
94 int64_t extra_offset_ms);
95
96 void PlotDelayHistogram(const std::string& title,
97 const std::string& bwe_name,
98 int num_flows,
99 int64_t one_way_path_delay_ms);
100
101 void PlotLossHistogram(const std::string& title,
102 const std::string& bwe_name,
103 int num_flows,
104 float global_loss_ratio);
105
106 void PlotObjectiveHistogram(const std::string& title,
107 const std::string& bwe_name,
108 int num_flows);
109
110 void set_start_computing_metrics_ms(int64_t start_computing_metrics_ms) {
111 start_computing_metrics_ms_ = start_computing_metrics_ms;
112 }
113
114 void set_plot_available_capacity(bool plot) {
115 plot_information_[kTotalAvailable].plot = plot;
116 }
117
118 void PauseFlow(); // Plot zero.
119 void ResumeFlow(int64_t paused_time_ms); // Plot zero.
120 void PlotZero();
121
122 private:
123 uint32_t GetTotalAvailableKbps();
124 uint32_t GetAvailablePerFlowKbps();
125 uint32_t GetSendingEstimateKbps();
126 double ObjectiveFunction();
127
128 double Renormalize(double x);
129 bool ShouldRecord(int64_t arrival_time_ms);
130
131 void PushDelayMs(int64_t delay_ms, int64_t arrival_time_ms);
132 void PushThroughputBytes(size_t throughput_bytes, int64_t arrival_time_ms);
133
134 enum Metrics {
135 kThroughput = 0,
136 kDelay,
137 kLoss,
138 kObjective,
139 kTotalAvailable,
140 kAvailablePerFlow,
141 kNumMetrics
142 };
143
144 std::string algorithm_name_;
145 int flow_id_;
146 PacketSender* packet_sender_;
147 LinkShare* link_share_;
148
149 int64_t now_ms_;
150
151 PlotInformation plot_information_[kNumMetrics];
152
153 std::vector<int64_t> delays_ms_;
154 std::vector<size_t> throughput_bytes_;
155 // (Receiving rate - available bitrate per flow) * time window.
156 std::vector<int64_t> weighted_estimate_error_;
157 int64_t last_unweighted_estimate_error_;
158 int64_t optimal_throughput_bits_;
159 int64_t last_available_bitrate_per_flow_kbps_;
160 int64_t start_computing_metrics_ms_;
161 bool started_computing_metrics_;
162 };
163
164 } // namespace bwe
165 } // namespace testing
166 } // namespace webrtc
167 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_METRIC_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698