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

Unified Diff: webrtc/tools/event_log_visualizer/analyzer.cc

Issue 2179223003: Convenience functions to set axis properties in visualization tool. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/tools/event_log_visualizer/analyzer.cc
diff --git a/webrtc/tools/event_log_visualizer/analyzer.cc b/webrtc/tools/event_log_visualizer/analyzer.cc
index e6dd35b6c6fa10e1d62f23cda08b2b36bf9ea792..ac4cf1bd301b1f4196d2f039669908249bb4b69d 100644
--- a/webrtc/tools/event_log_visualizer/analyzer.cc
+++ b/webrtc/tools/event_log_visualizer/analyzer.cc
@@ -76,10 +76,10 @@ int64_t WrappingDifference(uint32_t later, uint32_t earlier, int64_t modulus) {
return difference;
}
-const double kXMargin = 1.02;
-const double kYMargin = 1.1;
-const double kDefaultXMin = -1;
-const double kDefaultYMin = -1;
+const float kLeftMargin = 0.01;
danilchap 2016/07/26 10:52:46 can be constexpr
terelius 2016/07/26 17:37:38 Done.
+const float kRightMargin = 0.02;
+const float kBottomMargin = 0.02;
+const float kTopMargin = 0.05;
} // namespace
@@ -230,6 +230,7 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log)
}
begin_time_ = first_timestamp;
end_time_ = last_timestamp;
+ call_duration_s_ = static_cast<float>(end_time_ - begin_time_) / 1000000;
}
void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
@@ -240,7 +241,6 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
MediaType media_type;
uint8_t header[IP_PACKET_SIZE];
size_t header_length, total_length;
- float max_y = 0;
for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) {
ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i);
@@ -257,7 +257,6 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
uint64_t timestamp = parsed_log_.GetTimestamp(i);
float x = static_cast<float>(timestamp - begin_time_) / 1000000;
float y = total_length;
- max_y = std::max(max_y, y);
time_series[parsed_header.ssrc].points.push_back(
TimeSeriesPoint(x, y));
}
@@ -269,19 +268,16 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
for (auto& kv : time_series) {
kv.second.label = SsrcToString(kv.first);
kv.second.style = BAR_GRAPH;
- plot->series.push_back(std::move(kv.second));
+ plot->series_list_.push_back(std::move(kv.second));
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = kDefaultYMin;
- plot->yaxis_max = max_y * kYMargin;
- plot->yaxis_label = "Packet size (bytes)";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Packet size (bytes)", kBottomMargin,
+ kTopMargin);
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {
- plot->title = "Incoming RTP packets";
+ plot->SetTitle("Incoming RTP packets");
} else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) {
- plot->title = "Outgoing RTP packets";
+ plot->SetTitle("Outgoing RTP packets");
}
}
@@ -291,7 +287,6 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) {
std::map<uint32_t, uint64_t> last_playout;
uint32_t ssrc;
- float max_y = 0;
for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) {
ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i);
@@ -306,7 +301,6 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) {
// Generate a point, but place it on the x-axis.
y = 0;
}
- max_y = std::max(max_y, y);
time_series[ssrc].points.push_back(TimeSeriesPoint(x, y));
last_playout[ssrc] = timestamp;
}
@@ -317,16 +311,13 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) {
for (auto& kv : time_series) {
kv.second.label = SsrcToString(kv.first);
kv.second.style = BAR_GRAPH;
- plot->series.push_back(std::move(kv.second));
+ plot->series_list_.push_back(std::move(kv.second));
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = kDefaultYMin;
- plot->yaxis_max = max_y * kYMargin;
- plot->yaxis_label = "Time since last playout (ms)";
- plot->title = "Audio playout";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin,
+ kTopMargin);
+ plot->SetTitle("Audio playout");
}
// For each SSRC, plot the time between the consecutive playouts.
@@ -339,9 +330,6 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
uint8_t header[IP_PACKET_SIZE];
size_t header_length, total_length;
- int max_y = 1;
- int min_y = 0;
-
for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) {
ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i);
if (event_type == ParsedRtcEventLog::RTP_EVENT) {
@@ -363,8 +351,6 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
// Generate a point, but place it on the x-axis.
y = 0;
}
- max_y = std::max(max_y, y);
- min_y = std::min(min_y, y);
time_series[parsed_header.ssrc].points.push_back(
TimeSeriesPoint(x, y));
last_seqno[parsed_header.ssrc] = parsed_header.sequenceNumber;
@@ -377,22 +363,16 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
for (auto& kv : time_series) {
kv.second.label = SsrcToString(kv.first);
kv.second.style = BAR_GRAPH;
- plot->series.push_back(std::move(kv.second));
+ plot->series_list_.push_back(std::move(kv.second));
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_label = "Difference since last packet";
- plot->title = "Sequence number";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Difference since last packet", kBottomMargin,
+ kTopMargin);
+ plot->SetTitle("Sequence number");
}
void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) {
- double max_y = 10;
- double min_y = 0;
-
for (auto& kv : rtp_packets_) {
StreamId stream_id = kv.first;
// Filter on direction and SSRC.
@@ -427,28 +407,20 @@ void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) {
// Generate a point, but place it on the x-axis.
y = 0;
}
- max_y = std::max(max_y, y);
- min_y = std::min(min_y, y);
time_series.points.emplace_back(x, y);
}
}
// Add the data set to the plot.
- plot->series.push_back(std::move(time_series));
+ plot->series_list_.push_back(std::move(time_series));
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_label = "Latency change (ms)";
- plot->title = "Network latency change between consecutive packets";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin,
+ kTopMargin);
+ plot->SetTitle("Network latency change between consecutive packets");
}
void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) {
- double max_y = 10;
- double min_y = 0;
-
for (auto& kv : rtp_packets_) {
StreamId stream_id = kv.first;
// Filter on direction and SSRC.
@@ -483,22 +455,17 @@ void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) {
// Generate a point, but place it on the x-axis.
accumulated_delay_ms = 0;
}
- max_y = std::max(max_y, accumulated_delay_ms);
- min_y = std::min(min_y, accumulated_delay_ms);
time_series.points.emplace_back(x, accumulated_delay_ms);
}
}
// Add the data set to the plot.
- plot->series.push_back(std::move(time_series));
+ plot->series_list_.push_back(std::move(time_series));
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = min_y - (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_max = max_y + (kYMargin - 1) / 2 * (max_y - min_y);
- plot->yaxis_label = "Latency change (ms)";
- plot->title = "Accumulated network latency change";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Latency change (ms)", kBottomMargin,
+ kTopMargin);
+ plot->SetTitle("Accumulated network latency change");
}
// Plot the total bandwidth used by all RTP streams.
@@ -531,10 +498,9 @@ void EventLogAnalyzer::CreateTotalBitrateGraph(
size_t window_index_begin = 0;
size_t window_index_end = 0;
size_t bytes_in_window = 0;
- float max_y = 0;
// Calculate a moving average of the bitrate and store in a TimeSeries.
- plot->series.push_back(TimeSeries());
+ plot->series_list_.push_back(TimeSeries());
for (uint64_t time = begin_time_; time < end_time_ + step_; time += step_) {
while (window_index_end < packets.size() &&
packets[window_index_end].timestamp < time) {
@@ -551,42 +517,36 @@ void EventLogAnalyzer::CreateTotalBitrateGraph(
static_cast<float>(window_duration_) / 1000000;
float x = static_cast<float>(time - begin_time_) / 1000000;
float y = bytes_in_window * 8 / window_duration_in_seconds / 1000;
- max_y = std::max(max_y, y);
- plot->series.back().points.push_back(TimeSeriesPoint(x, y));
+ plot->series_list_.back().points.push_back(TimeSeriesPoint(x, y));
}
// Set labels.
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {
- plot->series.back().label = "Incoming bitrate";
+ plot->series_list_.back().label = "Incoming bitrate";
} else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) {
- plot->series.back().label = "Outgoing bitrate";
+ plot->series_list_.back().label = "Outgoing bitrate";
}
- plot->series.back().style = LINE_GRAPH;
+ plot->series_list_.back().style = LINE_GRAPH;
// Overlay the send-side bandwidth estimate over the outgoing bitrate.
if (desired_direction == kOutgoingPacket) {
- plot->series.push_back(TimeSeries());
+ plot->series_list_.push_back(TimeSeries());
for (auto& bwe_update : bwe_loss_updates_) {
float x =
static_cast<float>(bwe_update.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(bwe_update.new_bitrate) / 1000;
- max_y = std::max(max_y, y);
- plot->series.back().points.emplace_back(x, y);
+ plot->series_list_.back().points.emplace_back(x, y);
}
- plot->series.back().label = "Loss-based estimate";
- plot->series.back().style = LINE_GRAPH;
+ plot->series_list_.back().label = "Loss-based estimate";
+ plot->series_list_.back().style = LINE_GRAPH;
}
-
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = kDefaultYMin;
- plot->yaxis_max = max_y * kYMargin;
- plot->yaxis_label = "Bitrate (kbps)";
+ plot->series_list_.back().style = LINE_GRAPH;
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {
- plot->title = "Incoming RTP bitrate";
+ plot->SetTitle("Incoming RTP bitrate");
} else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) {
- plot->title = "Outgoing RTP bitrate";
+ plot->SetTitle("Outgoing RTP bitrate");
}
}
@@ -627,15 +587,13 @@ void EventLogAnalyzer::CreateStreamBitrateGraph(
}
}
- float max_y = 0;
-
for (auto& kv : packets) {
size_t window_index_begin = 0;
size_t window_index_end = 0;
size_t bytes_in_window = 0;
// Calculate a moving average of the bitrate and store in a TimeSeries.
- plot->series.push_back(TimeSeries());
+ plot->series_list_.push_back(TimeSeries());
for (uint64_t time = begin_time_; time < end_time_ + step_; time += step_) {
while (window_index_end < kv.second.size() &&
kv.second[window_index_end].timestamp < time) {
@@ -653,25 +611,20 @@ void EventLogAnalyzer::CreateStreamBitrateGraph(
static_cast<float>(window_duration_) / 1000000;
float x = static_cast<float>(time - begin_time_) / 1000000;
float y = bytes_in_window * 8 / window_duration_in_seconds / 1000;
- max_y = std::max(max_y, y);
- plot->series.back().points.push_back(TimeSeriesPoint(x, y));
+ plot->series_list_.back().points.push_back(TimeSeriesPoint(x, y));
}
// Set labels.
- plot->series.back().label = SsrcToString(kv.first);
- plot->series.back().style = LINE_GRAPH;
+ plot->series_list_.back().label = SsrcToString(kv.first);
+ plot->series_list_.back().style = LINE_GRAPH;
}
- plot->xaxis_min = kDefaultXMin;
- plot->xaxis_max = (end_time_ - begin_time_) / 1000000 * kXMargin;
- plot->xaxis_label = "Time (s)";
- plot->yaxis_min = kDefaultYMin;
- plot->yaxis_max = max_y * kYMargin;
- plot->yaxis_label = "Bitrate (kbps)";
+ plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
+ plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {
- plot->title = "Incoming bitrate per stream";
+ plot->SetTitle("Incoming bitrate per stream");
} else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) {
- plot->title = "Outgoing bitrate per stream";
+ plot->SetTitle("Outgoing bitrate per stream");
}
}

Powered by Google App Engine
This is Rietveld 408576698