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}
This commit is contained in:
terelius
2017-02-01 06:34:53 -08:00
committed by Commit bot
parent a565f92e87
commit 77f0580f83
5 changed files with 17 additions and 6 deletions

View File

@ -555,12 +555,11 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries(
TimeSeries time_series; TimeSeries time_series;
time_series.label = label_prefix + " " + GetStreamName(stream_id); 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++) { for (size_t i = 0; i < packet_stream.size(); i++) {
float x = static_cast<float>(packet_stream[i].timestamp - begin_time_) / float x = static_cast<float>(packet_stream[i].timestamp - begin_time_) /
1000000; 1000000;
time_series.points.emplace_back(x, i);
time_series.points.emplace_back(x, i + 1); time_series.points.emplace_back(x, i + 1);
} }
@ -893,9 +892,8 @@ void EventLogAnalyzer::CreateTotalBitrateGraph(
plot->series_list_.back().points.emplace_back(x, y); plot->series_list_.back().points.emplace_back(x, y);
} }
plot->series_list_.back().label = "Loss-based estimate"; 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->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) { if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {

View File

@ -9,6 +9,7 @@ message ChartStyle {
UNDEFINED = 0; UNDEFINED = 0;
LINE_CHART = 1; LINE_CHART = 1;
BAR_CHART = 2; BAR_CHART = 2;
LINE_STEP_CHART = 3;
} }
} }

View File

@ -18,7 +18,7 @@
namespace webrtc { namespace webrtc {
namespace plotting { 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 { struct TimeSeriesPoint {
TimeSeriesPoint(float x, float y) : x(x), y(y) {} TimeSeriesPoint(float x, float y) : x(x), y(y) {}

View File

@ -38,6 +38,8 @@ void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) {
} else if (series_list_[i].style == LINE_DOT_GRAPH) { } else if (series_list_[i].style == LINE_DOT_GRAPH) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART); data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
data_set->set_highlight_points(true); 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 { } else {
data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED); data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
} }

View File

@ -65,6 +65,16 @@ void PythonPlot::Draw() {
"plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', " "plt.plot(x%zu, y%zu, color=rgb_colors[%zu], label=\'%s\', "
"marker='.')\n", "marker='.')\n",
i, i, i, series_list_[i].label.c_str()); 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 { } else {
printf("raise Exception(\"Unknown graph type\")\n"); printf("raise Exception(\"Unknown graph type\")\n");
} }