Define a protobuf format for representing plots. Add code to convert the C-representation generated by the RtcEventLog analysis tool, to the new protobuf format.
BUG=webrtc:6249 NOTRY=True Review-Url: https://codereview.webrtc.org/2268063002 Cr-Commit-Position: refs/heads/master@{#13873}
This commit is contained in:
parent
6addf49913
commit
b246a292cd
@ -7,6 +7,7 @@
|
|||||||
# be found in the AUTHORS file in the root of the source tree.
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
import("//testing/test.gni")
|
import("//testing/test.gni")
|
||||||
|
import("//third_party/protobuf/proto_library.gni")
|
||||||
import("../build/webrtc.gni")
|
import("../build/webrtc.gni")
|
||||||
|
|
||||||
source_set("tools") {
|
source_set("tools") {
|
||||||
@ -175,12 +176,21 @@ source_set("agc_test_utils") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rtc_enable_protobuf) {
|
if (rtc_enable_protobuf) {
|
||||||
|
proto_library("graph_proto") {
|
||||||
|
sources = [
|
||||||
|
"event_log_visualizer/graph.proto",
|
||||||
|
]
|
||||||
|
proto_out_dir = "webrtc/tools/event_log_visualizer"
|
||||||
|
}
|
||||||
|
|
||||||
source_set("event_log_visualizer_utils") {
|
source_set("event_log_visualizer_utils") {
|
||||||
sources = [
|
sources = [
|
||||||
"event_log_visualizer/analyzer.cc",
|
"event_log_visualizer/analyzer.cc",
|
||||||
"event_log_visualizer/analyzer.h",
|
"event_log_visualizer/analyzer.h",
|
||||||
"event_log_visualizer/plot_base.cc",
|
"event_log_visualizer/plot_base.cc",
|
||||||
"event_log_visualizer/plot_base.h",
|
"event_log_visualizer/plot_base.h",
|
||||||
|
"event_log_visualizer/plot_protobuf.cc",
|
||||||
|
"event_log_visualizer/plot_protobuf.h",
|
||||||
"event_log_visualizer/plot_python.cc",
|
"event_log_visualizer/plot_python.cc",
|
||||||
"event_log_visualizer/plot_python.h",
|
"event_log_visualizer/plot_python.h",
|
||||||
]
|
]
|
||||||
@ -201,6 +211,7 @@ if (rtc_enable_protobuf) {
|
|||||||
"//build/config/sanitizers:deps",
|
"//build/config/sanitizers:deps",
|
||||||
]
|
]
|
||||||
public_deps = [
|
public_deps = [
|
||||||
|
":graph_proto",
|
||||||
"../:rtc_event_log_parser",
|
"../:rtc_event_log_parser",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
32
webrtc/tools/event_log_visualizer/graph.proto
Normal file
32
webrtc/tools/event_log_visualizer/graph.proto
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
option optimize_for = LITE_RUNTIME;
|
||||||
|
package webrtc.protobuf_plot;
|
||||||
|
|
||||||
|
enum PlotStyle {
|
||||||
|
UNDEFINED = 0;
|
||||||
|
LINE_GRAPH = 1;
|
||||||
|
LINE_DOT_GRAPH = 2;
|
||||||
|
BAR_GRAPH = 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
message DataSet {
|
||||||
|
repeated float xvalues = 1;
|
||||||
|
repeated float yvalues = 2;
|
||||||
|
optional string label = 3;
|
||||||
|
optional PlotStyle style = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Plot {
|
||||||
|
repeated DataSet data_sets = 1;
|
||||||
|
optional float xaxis_min = 2;
|
||||||
|
optional float xaxis_max = 3;
|
||||||
|
optional string xaxis_label = 4;
|
||||||
|
optional float yaxis_min = 5;
|
||||||
|
optional float yaxis_max = 6;
|
||||||
|
optional string yaxis_label = 7;
|
||||||
|
optional string title = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PlotCollection {
|
||||||
|
repeated Plot plots = 1;
|
||||||
|
}
|
||||||
81
webrtc/tools/event_log_visualizer/plot_protobuf.cc
Normal file
81
webrtc/tools/event_log_visualizer/plot_protobuf.cc
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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 "webrtc/tools/event_log_visualizer/plot_protobuf.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
namespace plotting {
|
||||||
|
|
||||||
|
ProtobufPlot::ProtobufPlot() {}
|
||||||
|
|
||||||
|
ProtobufPlot::~ProtobufPlot() {}
|
||||||
|
|
||||||
|
void ProtobufPlot::Draw() {}
|
||||||
|
|
||||||
|
void ProtobufPlot::ExportProtobuf(protobuf_plot::Plot* plot) {
|
||||||
|
for (size_t i = 0; i < series_list_.size(); i++) {
|
||||||
|
protobuf_plot::DataSet* data_set = plot->add_data_sets();
|
||||||
|
for (const auto& point : series_list_[i].points) {
|
||||||
|
data_set->add_xvalues(point.x);
|
||||||
|
}
|
||||||
|
for (const auto& point : series_list_[i].points) {
|
||||||
|
data_set->add_yvalues(point.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series_list_[i].style == BAR_GRAPH) {
|
||||||
|
data_set->set_style(protobuf_plot::BAR_GRAPH);
|
||||||
|
} else if (series_list_[i].style == LINE_GRAPH) {
|
||||||
|
data_set->set_style(protobuf_plot::LINE_GRAPH);
|
||||||
|
} else if (series_list_[i].style == LINE_DOT_GRAPH) {
|
||||||
|
data_set->set_style(protobuf_plot::LINE_DOT_GRAPH);
|
||||||
|
} else {
|
||||||
|
data_set->set_style(protobuf_plot::UNDEFINED);
|
||||||
|
}
|
||||||
|
|
||||||
|
data_set->set_label(series_list_[i].label);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot->set_xaxis_min(xaxis_min_);
|
||||||
|
plot->set_xaxis_max(xaxis_max_);
|
||||||
|
plot->set_yaxis_min(yaxis_min_);
|
||||||
|
plot->set_yaxis_max(yaxis_max_);
|
||||||
|
plot->set_xaxis_label(xaxis_label_);
|
||||||
|
plot->set_yaxis_label(yaxis_label_);
|
||||||
|
plot->set_title(title_);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtobufPlotCollection::ProtobufPlotCollection() {}
|
||||||
|
|
||||||
|
ProtobufPlotCollection::~ProtobufPlotCollection() {}
|
||||||
|
|
||||||
|
void ProtobufPlotCollection::Draw() {}
|
||||||
|
|
||||||
|
void ProtobufPlotCollection::ExportProtobuf(
|
||||||
|
protobuf_plot::PlotCollection* 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.
|
||||||
|
protobuf_plot::Plot* protobuf_representation = collection->add_plots();
|
||||||
|
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 plotting
|
||||||
|
} // namespace webrtc
|
||||||
39
webrtc/tools/event_log_visualizer/plot_protobuf.h
Normal file
39
webrtc/tools/event_log_visualizer/plot_protobuf.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_PROTOBUF_H_
|
||||||
|
#define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_PROTOBUF_H_
|
||||||
|
|
||||||
|
#include "webrtc/tools/event_log_visualizer/graph.pb.h"
|
||||||
|
#include "webrtc/tools/event_log_visualizer/plot_base.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
namespace plotting {
|
||||||
|
|
||||||
|
class ProtobufPlot final : public Plot {
|
||||||
|
public:
|
||||||
|
ProtobufPlot();
|
||||||
|
~ProtobufPlot() override;
|
||||||
|
void Draw() override;
|
||||||
|
void ExportProtobuf(protobuf_plot::Plot* plot);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ProtobufPlotCollection final : public PlotCollection {
|
||||||
|
public:
|
||||||
|
ProtobufPlotCollection();
|
||||||
|
~ProtobufPlotCollection() override;
|
||||||
|
void Draw() override;
|
||||||
|
Plot* AppendNewPlot() override;
|
||||||
|
void ExportProtobuf(protobuf_plot::PlotCollection* collection);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace plotting
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_PROTOBUF_H_
|
||||||
@ -101,6 +101,18 @@
|
|||||||
'conditions': [
|
'conditions': [
|
||||||
['enable_protobuf==1', {
|
['enable_protobuf==1', {
|
||||||
'targets': [
|
'targets': [
|
||||||
|
{
|
||||||
|
'target_name': 'graph_proto',
|
||||||
|
'type': 'static_library',
|
||||||
|
'sources': [
|
||||||
|
'event_log_visualizer/graph.proto',
|
||||||
|
],
|
||||||
|
'variables': {
|
||||||
|
'proto_in_dir': 'event_log_visualizer',
|
||||||
|
'proto_out_dir': 'webrtc/tools/event_log_visualizer',
|
||||||
|
},
|
||||||
|
'includes': ['../build/protoc.gypi'],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
# RTC event log visualization library
|
# RTC event log visualization library
|
||||||
'target_name': 'event_log_visualizer_utils',
|
'target_name': 'event_log_visualizer_utils',
|
||||||
@ -111,18 +123,22 @@
|
|||||||
'<(webrtc_root)/modules/modules.gyp:congestion_controller',
|
'<(webrtc_root)/modules/modules.gyp:congestion_controller',
|
||||||
'<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
|
'<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
|
||||||
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
|
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
|
||||||
|
':graph_proto',
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'event_log_visualizer/analyzer.cc',
|
'event_log_visualizer/analyzer.cc',
|
||||||
'event_log_visualizer/analyzer.h',
|
'event_log_visualizer/analyzer.h',
|
||||||
'event_log_visualizer/plot_base.cc',
|
'event_log_visualizer/plot_base.cc',
|
||||||
'event_log_visualizer/plot_base.h',
|
'event_log_visualizer/plot_base.h',
|
||||||
|
'event_log_visualizer/plot_protobuf.cc',
|
||||||
|
'event_log_visualizer/plot_protobuf.h',
|
||||||
'event_log_visualizer/plot_python.cc',
|
'event_log_visualizer/plot_python.cc',
|
||||||
'event_log_visualizer/plot_python.h',
|
'event_log_visualizer/plot_python.h',
|
||||||
],
|
],
|
||||||
'export_dependent_settings': [
|
'export_dependent_settings': [
|
||||||
'<(webrtc_root)/webrtc.gyp:rtc_event_log_parser',
|
'<(webrtc_root)/webrtc.gyp:rtc_event_log_parser',
|
||||||
],
|
':graph_proto',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user