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 |
11 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
12 | 12 |
13 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | 13 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
14 | 14 |
15 #include <stdarg.h> | 15 #include <stdarg.h> |
16 #include <stdio.h> | 16 #include <stdio.h> |
17 | 17 |
18 #include <algorithm> | 18 #include <algorithm> |
19 #include <sstream> | 19 #include <sstream> |
20 | 20 |
| 21 #include "webrtc/base/format_macros.h" |
21 #include "webrtc/base/platform_thread.h" | 22 #include "webrtc/base/platform_thread.h" |
22 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 23 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace testing { | 26 namespace testing { |
26 namespace bwe { | 27 namespace bwe { |
27 | 28 |
28 Logging Logging::g_Logging; | 29 Logging Logging::g_Logging; |
29 | 30 |
30 static std::string ToString(uint32_t v) { | 31 static std::string ToString(uint32_t v) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (state.enabled) { | 84 if (state.enabled) { |
84 printf("%s\t", state.tag.c_str()); | 85 printf("%s\t", state.tag.c_str()); |
85 va_list args; | 86 va_list args; |
86 va_start(args, format); | 87 va_start(args, format); |
87 vprintf(format, args); | 88 vprintf(format, args); |
88 va_end(args); | 89 va_end(args); |
89 printf("\n"); | 90 printf("\n"); |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 void Logging::Plot(int figure, double value) { | 94 void Logging::Plot(int figure, const std::string& name, double value) { |
94 Plot(figure, value, 0, "-"); | 95 Plot(figure, name, value, 0, "-"); |
95 } | |
96 | |
97 void Logging::Plot(int figure, double value, uint32_t ssrc) { | |
98 Plot(figure, value, ssrc, "-"); | |
99 } | |
100 | |
101 void Logging::Plot(int figure, double value, const std::string& alg_name) { | |
102 Plot(figure, value, 0, alg_name); | |
103 } | 96 } |
104 | 97 |
105 void Logging::Plot(int figure, | 98 void Logging::Plot(int figure, |
| 99 const std::string& name, |
| 100 double value, |
| 101 uint32_t ssrc) { |
| 102 Plot(figure, name, value, ssrc, "-"); |
| 103 } |
| 104 |
| 105 void Logging::Plot(int figure, |
| 106 const std::string& name, |
| 107 double value, |
| 108 const std::string& alg_name) { |
| 109 Plot(figure, name, value, 0, alg_name); |
| 110 } |
| 111 |
| 112 void Logging::Plot(int figure, |
| 113 const std::string& name, |
106 double value, | 114 double value, |
107 uint32_t ssrc, | 115 uint32_t ssrc, |
108 const std::string& alg_name) { | 116 const std::string& alg_name) { |
109 CriticalSectionScoped cs(crit_sect_.get()); | 117 CriticalSectionScoped cs(crit_sect_.get()); |
110 ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); | 118 ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); |
111 assert(it != thread_map_.end()); | 119 assert(it != thread_map_.end()); |
112 const State& state = it->second.stack.top(); | 120 const State& state = it->second.stack.top(); |
113 std::stringstream ss; | |
114 ss << ssrc; | |
115 std::string label = state.tag + ':' + ss.str() + '@' + alg_name; | |
116 std::string prefix("Available"); | |
117 if (alg_name.compare(0, prefix.length(), prefix) == 0) { | |
118 std::string receiver("Receiver"); | |
119 size_t start_pos = label.find(receiver); | |
120 if (start_pos != std::string::npos) { | |
121 label.replace(start_pos, receiver.length(), "Sender"); | |
122 } | |
123 } | |
124 if (state.enabled) { | 121 if (state.enabled) { |
125 printf("PLOT\t%d\t%s\t%f\t%f\n", figure, label.c_str(), | 122 printf("PLOT\t%d\t%s:%" PRIu32 "@%s\t%f\t%f\n", figure, name.c_str(), ssrc, |
126 state.timestamp_ms * 0.001, value); | 123 alg_name.c_str(), state.timestamp_ms * 0.001, value); |
127 } | 124 } |
128 } | 125 } |
129 | 126 |
130 void Logging::PlotBar(int figure, | 127 void Logging::PlotBar(int figure, |
131 const std::string& name, | 128 const std::string& name, |
132 double value, | 129 double value, |
133 int flow_id) { | 130 int flow_id) { |
134 CriticalSectionScoped cs(crit_sect_.get()); | 131 CriticalSectionScoped cs(crit_sect_.get()); |
135 ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); | 132 ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); |
136 assert(it != thread_map_.end()); | 133 assert(it != thread_map_.end()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Update time so that next log/plot will use the latest time seen so far | 251 // Update time so that next log/plot will use the latest time seen so far |
255 // in this call tree. | 252 // in this call tree. |
256 state->timestamp_ms = std::max(state->timestamp_ms, newest_timestamp_ms); | 253 state->timestamp_ms = std::max(state->timestamp_ms, newest_timestamp_ms); |
257 } | 254 } |
258 } | 255 } |
259 } // namespace bwe | 256 } // namespace bwe |
260 } // namespace testing | 257 } // namespace testing |
261 } // namespace webrtc | 258 } // namespace webrtc |
262 | 259 |
263 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | 260 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
OLD | NEW |