27#include <fmt/format.h>
28#include <plotly_plotter/figure.h>
29#include <plotly_plotter/figure_builders/line.h>
30#include <plotly_plotter/figure_builders/scatter.h>
31#include <plotly_plotter/write_html.h>
46 : parameter_name_(
std::move(parameter_name)),
47 custom_output_name_(
std::move(custom_output_name)),
49 name_for_file_(create_name_for_file(
50 parameter_name_, custom_output_name_, options_)) {}
53 -> const
util::Utf8String& {
54 return name_for_file_;
60 const std::vector<measurer::Measurement>& measurements,
61 const std::string& file_path) {
65 const auto& title = custom_output_name_.
str();
67 std::vector<param::ParameterName> parameter_names;
68 parameter_names.push_back(parameter_name_);
69 if (!options_.subplot_column_parameter_name().empty()) {
70 parameter_names.emplace_back(
71 options_.subplot_column_parameter_name().data());
73 if (!options_.subplot_row_parameter_name().empty()) {
74 parameter_names.emplace_back(
75 options_.subplot_row_parameter_name().data());
79 measurements, parameter_names, custom_output_name_);
80 auto figure_builder = plotly_plotter::figure_builders::line(data_table)
81 .x(parameter_name_.str().str())
82 .y(custom_output_name_.str().str())
84 .log_x(options_.log_parameter())
85 .log_y(options_.log_output());
87 figure_builder.error_y(fmt::format(
"Error of {}", custom_output_name_));
89 if (!options_.subplot_column_parameter_name().empty()) {
90 figure_builder.subplot_column(
91 options_.subplot_column_parameter_name().data());
93 if (!options_.subplot_row_parameter_name().empty()) {
94 figure_builder.subplot_row(
95 options_.subplot_row_parameter_name().data());
97 auto figure = figure_builder.create();
98 figure.title(title.str());
99 plotly_plotter::write_html(file_path, figure);
102auto ParameterToOutputLinePlot::create_name_for_file(
106 fmt::memory_buffer buffer;
107 fmt::format_to(std::back_inserter(buffer),
"{}_by_{}",
110 if (!options.subplot_column_parameter_name().empty()) {
111 fmt::format_to(std::back_inserter(buffer),
"_by_{}",
113 options.subplot_column_parameter_name().data())));
115 if (!options.subplot_row_parameter_name().empty()) {
116 fmt::format_to(std::back_inserter(buffer),
"_by_{}",
120 return util::Utf8String(std::string(buffer.data(), buffer.size()));
Class of names of groups of benchmarks.
auto str() const noexcept -> const util::Utf8String &
Get the string of the name.
Class of names of custom outputs.
Class of options for plots.
Class of names of measurers.
Class of names of parameters.
void write(const measurer::MeasurerName &measurer_name, const BenchmarkGroupName &group_name, const std::vector< measurer::Measurement > &measurements, const std::string &file_path) override
Write a plot.
ParameterToOutputLinePlot(param::ParameterName parameter_name, CustomOutputName custom_output_name, PlotOptions options)
Constructor.
auto name_for_file() const -> const util::Utf8String &override
Get a name for output files.
Class of UTF-8 encoded string.
Definition of constants for labels in plots.
Declaration of create_data_table function.
Declaration of escape_for_file_name function.
auto create_data_table_with_custom_output(const std::vector< measurer::Measurement > &measurements, const std::vector< param::ParameterName > ¶meter_names, const CustomOutputName &output_name) -> std::pair< plotly_plotter::data_table, bool >
Create a data table with a custom output.
constexpr const char * case_name_label
Label for case names in plots.
Namespace of utility functions and classes.
auto escape_for_file_name(const Utf8String &input) -> Utf8String
Escape a string for a file name.
Namespace of stat_bench source codes.
Definition of ParameterName class.
Definition of ParameterToOutputLinePlot class.
Declaration of check_glob_pattern function.
Definition of Utf8String class.