Add new step graph type to event log visualization tool. Currently used for bitrate estimate and accumulated packet count, but could in general be used for any metric that is piecewise constant.
BUG=None
Review-Url: https://codereview.webrtc.org/2653343004
Cr-Commit-Position: refs/heads/master@{#16399}
diff --git a/webrtc/tools/event_log_visualizer/analyzer.cc b/webrtc/tools/event_log_visualizer/analyzer.cc
index a45ec77..2c34012 100644
--- a/webrtc/tools/event_log_visualizer/analyzer.cc
+++ b/webrtc/tools/event_log_visualizer/analyzer.cc
@@ -555,12 +555,11 @@
TimeSeries time_series;
time_series.label = label_prefix + " " + GetStreamName(stream_id);
- time_series.style = LINE_GRAPH;
+ time_series.style = LINE_STEP_GRAPH;
for (size_t i = 0; i < packet_stream.size(); i++) {
float x = static_cast<float>(packet_stream[i].timestamp - begin_time_) /
1000000;
- time_series.points.emplace_back(x, i);
time_series.points.emplace_back(x, i + 1);
}
@@ -893,9 +892,8 @@
plot->series_list_.back().points.emplace_back(x, y);
}
plot->series_list_.back().label = "Loss-based estimate";
- plot->series_list_.back().style = LINE_GRAPH;
+ plot->series_list_.back().style = LINE_STEP_GRAPH;
}
- 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) {
diff --git a/webrtc/tools/event_log_visualizer/chart.proto b/webrtc/tools/event_log_visualizer/chart.proto
index 685b4bd..e005391 100644
--- a/webrtc/tools/event_log_visualizer/chart.proto
+++ b/webrtc/tools/event_log_visualizer/chart.proto
@@ -9,6 +9,7 @@
UNDEFINED = 0;
LINE_CHART = 1;
BAR_CHART = 2;
+ LINE_STEP_CHART = 3;
}
}
@@ -33,4 +34,4 @@
message ChartCollection {
repeated Chart charts = 1;
-}
\ No newline at end of file
+}
diff --git a/webrtc/tools/event_log_visualizer/plot_base.h b/webrtc/tools/event_log_visualizer/plot_base.h
index 5546271..e2bec2d 100644
--- a/webrtc/tools/event_log_visualizer/plot_base.h
+++ b/webrtc/tools/event_log_visualizer/plot_base.h
@@ -18,7 +18,7 @@
namespace webrtc {
namespace plotting {
-enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH };
+enum PlotStyle { LINE_GRAPH, LINE_DOT_GRAPH, BAR_GRAPH, LINE_STEP_GRAPH };
struct TimeSeriesPoint {
TimeSeriesPoint(float x, float y) : x(x), y(y) {}
diff --git a/webrtc/tools/event_log_visualizer/plot_protobuf.cc b/webrtc/tools/event_log_visualizer/plot_protobuf.cc
index e6e1adc..6e45585 100644
--- a/webrtc/tools/event_log_visualizer/plot_protobuf.cc
+++ b/webrtc/tools/event_log_visualizer/plot_protobuf.cc
@@ -38,6 +38,8 @@
} else if (series_list_[i].style == LINE_DOT_GRAPH) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
data_set->set_highlight_points(true);
+ } else if (series_list_[i].style == LINE_STEP_GRAPH) {
+ data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART);
} else {
data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
}
diff --git a/webrtc/tools/event_log_visualizer/plot_python.cc b/webrtc/tools/event_log_visualizer/plot_python.cc
index d458344..c91efe3 100644
--- a/webrtc/tools/event_log_visualizer/plot_python.cc
+++ b/webrtc/tools/event_log_visualizer/plot_python.cc
@@ -65,6 +65,16 @@
"plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', "
"marker='.')\n",
i, i, i, series_list_[i].label.c_str());
+ } else if (series_list_[i].style == LINE_STEP_GRAPH) {
+ // Draw lines from (x[0],y[0]) to (x[1],y[0]) to (x[1],y[1]) and so on
+ // to illustrate the "steps". This can be expressed by duplicating all
+ // elements except the first in x and the last in y.
+ printf("x%zu = [v for dup in x%zu for v in [dup, dup]]\n", i, i);
+ printf("y%zu = [v for dup in y%zu for v in [dup, dup]]\n", i, i);
+ printf(
+ "plt.plot(x%zu[1:], y%zu[:-1], color=rgb_colors[%zu], "
+ "label=\'%s\')\n",
+ i, i, i, series_list_[i].label.c_str());
} else {
printf("raise Exception(\"Unknown graph type\")\n");
}