webrtc/rtc_tools/event_log_visualizer/plot_protobuf.cc
Bjorn Terelius 1aa9ee92f8 Add string-based IDs for event log visualizer graphs and update command line flags.
The IDs be more stable than the plot titles and could be used to identify specific graphs in scripts.

Change event_log_visualizer command line interface to control which plots are generated.
Old interface had one command line flag per plot as well as a set of 'profiles' that enabled
of disabled sets of plots. New interface has a command line flag
which takes a string of all the plot names or profiles that should be enabled.
In some cases, there are also slight naming changes for the plots.

For example, the former command
event_log_visualizer --plot_profile=sendside_bwe --plot_incoming_packet_sizes <filename> | python
is now
event_log_visualizer --plot=sendside_bwe,incoming_packet_sizes <filename> | python

The former command
event_log_visualizer --plot_profile=none --plot_incoming_packet_sizes <filename> | python
is now
event_log_visualizer --plot=incoming_packet_sizes <filename> | python

The former command
event_log_visualizer --plot_profile=all <filename> | python
is now
event_log_visualizer --plot=all <filename> | python


Bug: webrtc:10623
Change-Id: Ife432c1e51edfce64af565a769f1764a16655bb6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140886
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28237}
2019-06-11 16:41:50 +00:00

93 lines
3 KiB
C++

/*
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_tools/event_log_visualizer/plot_protobuf.h"
#include <stddef.h>
#include <iostream>
#include <memory>
#include <vector>
namespace webrtc {
ProtobufPlot::ProtobufPlot() {}
ProtobufPlot::~ProtobufPlot() {}
void ProtobufPlot::Draw() {}
void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) {
for (size_t i = 0; i < series_list_.size(); i++) {
webrtc::analytics::DataSet* data_set = chart->add_data_sets();
for (const auto& point : series_list_[i].points) {
data_set->add_x_values(point.x);
}
for (const auto& point : series_list_[i].points) {
data_set->add_y_values(point.y);
}
if (series_list_[i].line_style == LineStyle::kBar) {
data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART);
} else if (series_list_[i].line_style == LineStyle::kLine) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
} else if (series_list_[i].line_style == LineStyle::kStep) {
data_set->set_style(webrtc::analytics::ChartStyle::LINE_STEP_CHART);
} else if (series_list_[i].line_style == LineStyle::kNone) {
data_set->set_style(webrtc::analytics::ChartStyle::SCATTER_CHART);
} else {
data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
}
if (series_list_[i].point_style == PointStyle::kHighlight)
data_set->set_highlight_points(true);
data_set->set_label(series_list_[i].label);
}
chart->set_xaxis_min(xaxis_min_);
chart->set_xaxis_max(xaxis_max_);
chart->set_yaxis_min(yaxis_min_);
chart->set_yaxis_max(yaxis_max_);
chart->set_xaxis_label(xaxis_label_);
chart->set_yaxis_label(yaxis_label_);
chart->set_title(title_);
chart->set_id(id_);
}
ProtobufPlotCollection::ProtobufPlotCollection() {}
ProtobufPlotCollection::~ProtobufPlotCollection() {}
void ProtobufPlotCollection::Draw() {
webrtc::analytics::ChartCollection collection;
ExportProtobuf(&collection);
std::cout << collection.SerializeAsString();
}
void ProtobufPlotCollection::ExportProtobuf(
webrtc::analytics::ChartCollection* collection) {
for (const auto& plot : plots_) {
// TODO(terelius): Ensure that there is no way to insert plots other than
// ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast
// here.
webrtc::analytics::Chart* protobuf_representation =
collection->add_charts();
static_cast<ProtobufPlot*>(plot.get())
->ExportProtobuf(protobuf_representation);
}
}
Plot* ProtobufPlotCollection::AppendNewPlot() {
Plot* plot = new ProtobufPlot();
plots_.push_back(std::unique_ptr<Plot>(plot));
return plot;
}
} // namespace webrtc