OLD | NEW |
---|---|
(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 template <typename T> | |
43 void Update(int64_t now_ms, T value) { | |
44 time_ms = now_ms; | |
45 value = static_cast<double>(value); | |
46 } | |
47 std::string prefix; | |
48 bool plot; | |
49 int64_t last_plot_ms; | |
50 int64_t time_ms; | |
51 double value; | |
52 int64_t plot_interval_ms; | |
53 }; | |
54 | |
55 class MetricRecorder { | |
56 public: | |
57 explicit MetricRecorder(const std::string algorithm_name, | |
stefan-webrtc
2015/07/03 09:32:11
No explicit since this takes multiple args
magalhaesc
2015/07/03 11:55:13
Done.
| |
58 int flow_id, | |
59 PacketSender* packet_sender, | |
60 LinkShare* link_share); | |
61 | |
62 void SetPlotInformation(const std::vector<std::string>& prefixs); | |
63 | |
64 void PlotLine(int windows_id, | |
65 const std::string& prefix, | |
66 int64_t x, | |
67 int64_t y); | |
68 | |
69 void PlotDynamics(int metric); | |
70 void PlotAllDynamics(); | |
71 | |
72 void UpdateTime(int64_t time_ms); | |
73 void UpdateThroughput(int64_t bitrate_kbps, size_t payload_size); | |
74 void UpdateDelay(int64_t delay_ms); | |
75 void UpdateLoss(float loss_ratio); | |
76 void UpdateObjective(); | |
77 | |
78 void PlotThroughputHistogram(const std::string& title, | |
79 const std::string& bwe_name, | |
80 int num_flows, | |
81 int64_t extra_offset_ms, | |
82 const std::string optimum_id); | |
83 | |
84 void PlotThroughputHistogram(const std::string& title, | |
85 const std::string& bwe_name, | |
86 int num_flows, | |
87 int64_t extra_offset_ms); | |
88 | |
89 void PlotDelayHistogram(const std::string& title, | |
90 const std::string& bwe_name, | |
91 int num_flows); | |
92 | |
93 void PlotLossHistogram(const std::string& title, | |
94 const std::string& bwe_name, | |
95 int num_flows, | |
96 float global_loss_ratio); | |
97 | |
98 void PlotObjectiveHistogram(const std::string& title, | |
99 const std::string& bwe_name, | |
100 int num_flows); | |
101 | |
102 void set_start_computing_metrics_ms(int64_t start_computing_metrics_ms) { | |
103 start_computing_metrics_ms_ = start_computing_metrics_ms; | |
104 } | |
105 | |
106 private: | |
107 uint32_t GetTotalAvailableKbps(); | |
108 uint32_t GetAvailablePerFlowKbps(); | |
109 uint32_t GetSendingEstimateKbps(); | |
110 double ObjectiveFunction(); | |
111 | |
112 double Renormalize(double x); | |
113 bool ShouldRecord(int64_t arrival_time_ms); | |
114 | |
115 void PushDelayMs(int64_t delay_ms, int64_t arrival_time_ms); | |
116 void PushThroughputBytes(size_t throughput_bytes, int64_t arrival_time_ms); | |
117 | |
118 enum Metrics { | |
119 kThroughput = 0, | |
120 kDelay, | |
121 kLoss, | |
122 kObjective, | |
123 kTotalAvailable, | |
124 kAvailablePerFlow, | |
125 kNumMetrics | |
126 }; | |
127 | |
128 std::string algorithm_name_; | |
129 int flow_id_; | |
130 PacketSender* packet_sender_; | |
131 LinkShare* link_share_; | |
132 | |
133 int64_t now_ms_; | |
134 | |
135 PlotInformation plot_information_[kNumMetrics]; | |
136 | |
137 std::vector<int64_t> delays_ms_; | |
138 std::vector<size_t> throughput_bytes_; | |
139 // (Receiving rate - available bitrate per flow) * time window. | |
140 std::vector<int64_t> weighted_estimate_error_; | |
141 int64_t last_unweighted_estimate_error_; | |
142 int64_t optimal_throughput_bits_; | |
143 int64_t last_available_bitrate_per_flow_kbps_; | |
144 int64_t start_computing_metrics_ms_; | |
145 bool started_computing_metrics_; | |
146 }; | |
147 | |
148 } // namespace bwe | |
149 } // namespace testing | |
150 } // namespace webrtc | |
151 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_METRIC_RECORDER_H_ | |
OLD | NEW |