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 printf("%s\t", state.tag.c_str()); | 84 printf("%s\t", state.tag.c_str()); |
85 va_list args; | 85 va_list args; |
86 va_start(args, format); | 86 va_start(args, format); |
87 vprintf(format, args); | 87 vprintf(format, args); |
88 va_end(args); | 88 va_end(args); |
89 printf("\n"); | 89 printf("\n"); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 void Logging::Plot(int figure, double value) { | 93 void Logging::Plot(int figure, double value) { |
| 94 Plot(figure, value, ""); |
| 95 } |
| 96 |
| 97 void Logging::Plot(int figure, double value, const std::string& alg_name) { |
| 98 CriticalSectionScoped cs(crit_sect_.get()); |
| 99 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
| 100 assert(it != thread_map_.end()); |
| 101 const State& state = it->second.stack.top(); |
| 102 std::string label = state.tag + '@' + alg_name; |
| 103 std::string prefix("Available"); |
| 104 if (alg_name.compare(0, prefix.length(), prefix) == 0) { |
| 105 std::string receiver("Receiver"); |
| 106 size_t start_pos = label.find(receiver); |
| 107 if (start_pos != std::string::npos) { |
| 108 label.replace(start_pos, receiver.length(), "Sender"); |
| 109 } |
| 110 } |
| 111 if (state.enabled) { |
| 112 printf("PLOT\t%d\t%s\t%f\t%f\n", figure, label.c_str(), |
| 113 state.timestamp_ms * 0.001, value); |
| 114 } |
| 115 } |
| 116 |
| 117 void Logging::PlotBar(int figure, |
| 118 const std::string& name, |
| 119 double value, |
| 120 int flow_id) { |
94 CriticalSectionScoped cs(crit_sect_.get()); | 121 CriticalSectionScoped cs(crit_sect_.get()); |
95 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); | 122 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
96 assert(it != thread_map_.end()); | 123 assert(it != thread_map_.end()); |
97 const State& state = it->second.stack.top(); | 124 const State& state = it->second.stack.top(); |
98 if (state.enabled) { | 125 if (state.enabled) { |
99 printf("PLOT\t%d\t%s\t%f\t%f\n", figure, state.tag.c_str(), | 126 printf("BAR\t%d\t%s_%d\t%f\n", figure, name.c_str(), flow_id, value); |
100 state.timestamp_ms * 0.001, value); | 127 } |
| 128 } |
| 129 |
| 130 void Logging::PlotBaselineBar(int figure, |
| 131 const std::string& name, |
| 132 double value, |
| 133 int flow_id) { |
| 134 CriticalSectionScoped cs(crit_sect_.get()); |
| 135 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
| 136 assert(it != thread_map_.end()); |
| 137 const State& state = it->second.stack.top(); |
| 138 if (state.enabled) { |
| 139 printf("BASELINE\t%d\t%s_%d\t%f\n", figure, name.c_str(), flow_id, value); |
| 140 } |
| 141 } |
| 142 |
| 143 void Logging::PlotErrorBar(int figure, |
| 144 const std::string& name, |
| 145 double value, |
| 146 double ylow, |
| 147 double yhigh, |
| 148 const std::string& error_title, |
| 149 int flow_id) { |
| 150 CriticalSectionScoped cs(crit_sect_.get()); |
| 151 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
| 152 assert(it != thread_map_.end()); |
| 153 const State& state = it->second.stack.top(); |
| 154 if (state.enabled) { |
| 155 printf("ERRORBAR\t%d\t%s_%d\t%f\t%f\t%f\t%s\n", figure, name.c_str(), |
| 156 flow_id, value, ylow, yhigh, error_title.c_str()); |
| 157 } |
| 158 } |
| 159 |
| 160 void Logging::PlotLimitErrorBar(int figure, |
| 161 const std::string& name, |
| 162 double value, |
| 163 double ylow, |
| 164 double yhigh, |
| 165 const std::string& error_title, |
| 166 double ymax, |
| 167 const std::string& limit_title, |
| 168 int flow_id) { |
| 169 CriticalSectionScoped cs(crit_sect_.get()); |
| 170 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
| 171 assert(it != thread_map_.end()); |
| 172 const State& state = it->second.stack.top(); |
| 173 if (state.enabled) { |
| 174 printf("LIMITERRORBAR\t%d\t%s_%d\t%f\t%f\t%f\t%s\t%f\t%s\n", figure, |
| 175 name.c_str(), flow_id, value, ylow, yhigh, error_title.c_str(), ymax, |
| 176 limit_title.c_str()); |
| 177 } |
| 178 } |
| 179 |
| 180 void Logging::PlotLabel(int figure, |
| 181 const std::string& title, |
| 182 const std::string& y_label, |
| 183 int num_flows) { |
| 184 CriticalSectionScoped cs(crit_sect_.get()); |
| 185 ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); |
| 186 assert(it != thread_map_.end()); |
| 187 const State& state = it->second.stack.top(); |
| 188 if (state.enabled) { |
| 189 printf("LABEL\t%d\t%s\t%s\t%d\n", figure, title.c_str(), y_label.c_str(), |
| 190 num_flows); |
101 } | 191 } |
102 } | 192 } |
103 | 193 |
104 Logging::Logging() | 194 Logging::Logging() |
105 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 195 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
106 thread_map_() { | 196 thread_map_() { |
107 } | 197 } |
108 | 198 |
109 Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {} | 199 Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {} |
110 | 200 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // Update time so that next log/plot will use the latest time seen so far | 241 // Update time so that next log/plot will use the latest time seen so far |
152 // in this call tree. | 242 // in this call tree. |
153 state->timestamp_ms = std::max(state->timestamp_ms, newest_timestamp_ms); | 243 state->timestamp_ms = std::max(state->timestamp_ms, newest_timestamp_ms); |
154 } | 244 } |
155 } | 245 } |
156 } // namespace bwe | 246 } // namespace bwe |
157 } // namespace testing | 247 } // namespace testing |
158 } // namespace webrtc | 248 } // namespace webrtc |
159 | 249 |
160 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE | 250 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE |
OLD | NEW |