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

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: Comments addressed [4] 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, const std::string& prefix, int64_t x, T y);
stefan-webrtc 2015/07/07 12:46:37 Maybe switch x for time_ms?
magalhaesc 2015/07/08 18:12:31 Done.
72
73 void PlotDynamics(int metric);
74 void PlotAllDynamics();
75
76 void UpdateTime(int64_t time_ms);
77 void UpdateThroughput(int64_t bitrate_kbps, size_t payload_size);
78 void UpdateDelay(int64_t delay_ms);
79 void UpdateLoss(float loss_ratio);
80 void UpdateObjective();
81
82 void PlotThroughputHistogram(const std::string& title,
83 const std::string& bwe_name,
84 int num_flows,
85 int64_t extra_offset_ms,
86 const std::string optimum_id);
87
88 void PlotThroughputHistogram(const std::string& title,
89 const std::string& bwe_name,
90 int num_flows,
91 int64_t extra_offset_ms);
92
93 void PlotDelayHistogram(const std::string& title,
94 const std::string& bwe_name,
95 int num_flows);
96
97 void PlotLossHistogram(const std::string& title,
98 const std::string& bwe_name,
99 int num_flows,
100 float global_loss_ratio);
101
102 void PlotObjectiveHistogram(const std::string& title,
103 const std::string& bwe_name,
104 int num_flows);
105
106 void set_start_computing_metrics_ms(int64_t start_computing_metrics_ms) {
107 start_computing_metrics_ms_ = start_computing_metrics_ms;
108 }
109
110 void set_plot_available_capacity(bool plot) {
111 plot_information_[kTotalAvailable].plot = plot;
112 }
113
114 void PauseFlow(); // Plot zero.
115 void ResumeFlow(int64_t paused_time_ms); // Plot zero.
116 void PlotZero();
117
118 private:
119 uint32_t GetTotalAvailableKbps();
120 uint32_t GetAvailablePerFlowKbps();
121 uint32_t GetSendingEstimateKbps();
122 double ObjectiveFunction();
123
124 double Renormalize(double x);
125 bool ShouldRecord(int64_t arrival_time_ms);
126
127 void PushDelayMs(int64_t delay_ms, int64_t arrival_time_ms);
128 void PushThroughputBytes(size_t throughput_bytes, int64_t arrival_time_ms);
129
130 enum Metrics {
131 kThroughput = 0,
132 kDelay,
133 kLoss,
134 kObjective,
135 kTotalAvailable,
136 kAvailablePerFlow,
137 kNumMetrics
138 };
139
140 std::string algorithm_name_;
141 int flow_id_;
142 PacketSender* packet_sender_;
143 LinkShare* link_share_;
144
145 int64_t now_ms_;
146
147 PlotInformation plot_information_[kNumMetrics];
148
149 std::vector<int64_t> delays_ms_;
150 std::vector<size_t> throughput_bytes_;
151 // (Receiving rate - available bitrate per flow) * time window.
152 std::vector<int64_t> weighted_estimate_error_;
153 int64_t last_unweighted_estimate_error_;
154 int64_t optimal_throughput_bits_;
155 int64_t last_available_bitrate_per_flow_kbps_;
156 int64_t start_computing_metrics_ms_;
157 bool started_computing_metrics_;
158 };
159
160 } // namespace bwe
161 } // namespace testing
162 } // namespace webrtc
163 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_METRIC_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698