OLD | NEW |
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) | 84 #define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) |
85 #define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) | 85 #define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) |
86 #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) | 86 #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) |
87 | 87 |
88 // Print to stdout in tab-separated format suitable for plotting, e.g.: | 88 // Print to stdout in tab-separated format suitable for plotting, e.g.: |
89 // PLOT figure Context1_Context2_Name time value | 89 // PLOT figure Context1_Context2_Name time value |
90 // |figure| is a figure id. Different figures are plotted in different windows. | 90 // |figure| is a figure id. Different figures are plotted in different windows. |
91 // |name| is a char*, std::string or uint32_t to name the plotted value. | 91 // |name| is a char*, std::string or uint32_t to name the plotted value. |
92 // |time| is an int64_t time in ms, or -1 to inherit time from previous context. | 92 // |time| is an int64_t time in ms, or -1 to inherit time from previous context. |
93 // |value| is a double precision float to be plotted. | 93 // |value| is a double precision float to be plotted. |
| 94 // |alg_name| is an optional argument, a string |
94 #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) | 95 #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) |
| 96 #define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) |
| 97 |
| 98 // Print to stdout in tab-separated format suitable for plotting, e.g.: |
| 99 // BAR figure Context1_Context2_Name x_left width value |
| 100 // |figure| is a figure id. Different figures are plotted in different windows. |
| 101 // |name| is a char*, std::string or uint32_t to name the plotted value. |
| 102 // |value| is a double precision float to be plotted. |
| 103 // |ylow| and |yhigh| are double precision float for the error line. |
| 104 // |title| is a string and refers to the error label. |
| 105 // |ymax| is a double precision float for the limit horizontal line. |
| 106 // |limit_title| is a string and refers to the limit label. |
| 107 #define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) |
| 108 #define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, \ |
| 109 error_title, flow_id) |
| 110 #define BWE_TEST_LOGGING_LIMITERRORBAR( \ |
| 111 figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) |
| 112 |
| 113 #define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) |
| 114 |
| 115 // |num_flows| is an integer refering to the number of RMCAT flows in the |
| 116 // scenario. |
| 117 // Define |x_label| and |y_label| for plots. |
| 118 #define BWE_TEST_LOGGING_LABEL(figure, x_label, y_label, num_flows) |
95 | 119 |
96 #else // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | 120 #else // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
97 | 121 |
98 #include <map> | 122 #include <map> |
99 #include <stack> | 123 #include <stack> |
100 #include <string> | 124 #include <string> |
101 | 125 |
102 #include "webrtc/base/constructormagic.h" | 126 #include "webrtc/base/constructormagic.h" |
103 #include "webrtc/base/scoped_ptr.h" | 127 #include "webrtc/base/scoped_ptr.h" |
104 #include "webrtc/common_types.h" | 128 #include "webrtc/common_types.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } while (0); | 174 } while (0); |
151 #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ | 175 #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ |
152 do {\ | 176 do {\ |
153 BWE_TEST_LOGGING_CONTEXT(name); \ | 177 BWE_TEST_LOGGING_CONTEXT(name); \ |
154 webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ | 178 webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ |
155 _4, _5); \ | 179 _4, _5); \ |
156 } while (0); | 180 } while (0); |
157 | 181 |
158 #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ | 182 #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ |
159 do { \ | 183 do { \ |
160 __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, \ | 184 __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ |
161 static_cast<int64_t>(time), true); \ | 185 static_cast<int64_t>(time), true); \ |
162 webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value); \ | 186 webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value); \ |
163 } while (0); | 187 } while (0); |
164 | 188 |
| 189 #define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) \ |
| 190 do { \ |
| 191 __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ |
| 192 static_cast<int64_t>(time), true); \ |
| 193 webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value, \ |
| 194 alg_name); \ |
| 195 } while (0); |
| 196 |
| 197 #define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) \ |
| 198 do { \ |
| 199 BWE_TEST_LOGGING_CONTEXT(name); \ |
| 200 webrtc::testing::bwe::Logging::GetInstance()->PlotBar(figure, name, value, \ |
| 201 flow_id); \ |
| 202 } while (0); |
| 203 |
| 204 #define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) \ |
| 205 do { \ |
| 206 BWE_TEST_LOGGING_CONTEXT(name); \ |
| 207 webrtc::testing::bwe::Logging::GetInstance()->PlotBaselineBar( \ |
| 208 figure, name, value, flow_id); \ |
| 209 } while (0); |
| 210 |
| 211 #define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, title, \ |
| 212 flow_id) \ |
| 213 do { \ |
| 214 BWE_TEST_LOGGING_CONTEXT(name); \ |
| 215 webrtc::testing::bwe::Logging::GetInstance()->PlotErrorBar( \ |
| 216 figure, name, value, ylow, yhigh, title, flow_id); \ |
| 217 } while (0); |
| 218 |
| 219 #define BWE_TEST_LOGGING_LIMITERRORBAR( \ |
| 220 figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) \ |
| 221 do { \ |
| 222 BWE_TEST_LOGGING_CONTEXT(name); \ |
| 223 webrtc::testing::bwe::Logging::GetInstance()->PlotLimitErrorBar( \ |
| 224 figure, name, value, ylow, yhigh, error_title, ymax, limit_title, \ |
| 225 flow_id); \ |
| 226 } while (0); |
| 227 |
| 228 #define BWE_TEST_LOGGING_LABEL(figure, title, y_label, num_flows) \ |
| 229 do { \ |
| 230 BWE_TEST_LOGGING_CONTEXT(title); \ |
| 231 webrtc::testing::bwe::Logging::GetInstance()->PlotLabel( \ |
| 232 figure, title, y_label, num_flows); \ |
| 233 } while (0); |
| 234 |
165 namespace webrtc { | 235 namespace webrtc { |
166 | 236 |
167 class CriticalSectionWrapper; | 237 class CriticalSectionWrapper; |
168 | 238 |
169 namespace testing { | 239 namespace testing { |
170 namespace bwe { | 240 namespace bwe { |
171 | 241 |
172 class Logging { | 242 class Logging { |
173 public: | 243 public: |
174 class Context { | 244 class Context { |
175 public: | 245 public: |
176 Context(uint32_t name, int64_t timestamp_ms, bool enabled); | 246 Context(uint32_t name, int64_t timestamp_ms, bool enabled); |
177 Context(const std::string& name, int64_t timestamp_ms, bool enabled); | 247 Context(const std::string& name, int64_t timestamp_ms, bool enabled); |
178 Context(const char* name, int64_t timestamp_ms, bool enabled); | 248 Context(const char* name, int64_t timestamp_ms, bool enabled); |
179 ~Context(); | 249 ~Context(); |
180 private: | 250 private: |
181 DISALLOW_IMPLICIT_CONSTRUCTORS(Context); | 251 DISALLOW_IMPLICIT_CONSTRUCTORS(Context); |
182 }; | 252 }; |
183 | 253 |
184 static Logging* GetInstance(); | 254 static Logging* GetInstance(); |
185 | 255 |
186 void SetGlobalContext(uint32_t name); | 256 void SetGlobalContext(uint32_t name); |
187 void SetGlobalContext(const std::string& name); | 257 void SetGlobalContext(const std::string& name); |
188 void SetGlobalContext(const char* name); | 258 void SetGlobalContext(const char* name); |
189 void SetGlobalEnable(bool enabled); | 259 void SetGlobalEnable(bool enabled); |
190 | 260 |
191 void Log(const char format[], ...); | 261 void Log(const char format[], ...); |
192 void Plot(int figure, double value); | 262 void Plot(int figure, double value); |
| 263 void Plot(int figure, double value, const std::string& alg_name); |
| 264 void PlotBar(int figure, const std::string& name, double value, int flow_id); |
| 265 void PlotBaselineBar(int figure, |
| 266 const std::string& name, |
| 267 double value, |
| 268 int flow_id); |
| 269 void PlotErrorBar(int figure, |
| 270 const std::string& name, |
| 271 double value, |
| 272 double ylow, |
| 273 double yhigh, |
| 274 const std::string& error_title, |
| 275 int flow_id); |
| 276 |
| 277 void PlotLimitErrorBar(int figure, |
| 278 const std::string& name, |
| 279 double value, |
| 280 double ylow, |
| 281 double yhigh, |
| 282 const std::string& error_title, |
| 283 double ymax, |
| 284 const std::string& limit_title, |
| 285 int flow_id); |
| 286 void PlotLabel(int figure, |
| 287 const std::string& title, |
| 288 const std::string& y_label, |
| 289 int num_flows); |
193 | 290 |
194 private: | 291 private: |
195 struct State { | 292 struct State { |
196 State(); | 293 State(); |
197 State(const std::string& new_tag, int64_t timestamp_ms, bool enabled); | 294 State(const std::string& new_tag, int64_t timestamp_ms, bool enabled); |
198 void MergePrevious(const State& previous); | 295 void MergePrevious(const State& previous); |
199 | 296 |
200 std::string tag; | 297 std::string tag; |
201 int64_t timestamp_ms; | 298 int64_t timestamp_ms; |
202 bool enabled; | 299 bool enabled; |
(...skipping 14 matching lines...) Expand all Loading... |
217 ThreadMap thread_map_; | 314 ThreadMap thread_map_; |
218 | 315 |
219 DISALLOW_COPY_AND_ASSIGN(Logging); | 316 DISALLOW_COPY_AND_ASSIGN(Logging); |
220 }; | 317 }; |
221 } // namespace bwe | 318 } // namespace bwe |
222 } // namespace testing | 319 } // namespace testing |
223 } // namespace webrtc | 320 } // namespace webrtc |
224 | 321 |
225 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | 322 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
226 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_LOGGING_H_ | 323 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_LOGGING_H_ |
OLD | NEW |