/builds/MusicScience37Projects/utility-libraries/cpp-stat-bench/src/stat_bench/plots/samples_line_plot.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2025 MusicScience37 (Kenta Kabashima) |
3 | | * |
4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | * you may not use this file except in compliance with the License. |
6 | | * You may obtain a copy of the License at |
7 | | * |
8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | * |
10 | | * Unless required by applicable law or agreed to in writing, software |
11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | * See the License for the specific language governing permissions and |
14 | | * limitations under the License. |
15 | | */ |
16 | | /*! |
17 | | * \file |
18 | | * \brief Implementation of SamplesLinePlot class. |
19 | | */ |
20 | | #include "stat_bench/plots/samples_line_plot.h" |
21 | | |
22 | | #include <vector> |
23 | | |
24 | | #include <plotly_plotter/figure.h> |
25 | | #include <plotly_plotter/figure_builders/line.h> |
26 | | #include <plotly_plotter/figure_builders/scatter.h> |
27 | | #include <plotly_plotter/write_html.h> |
28 | | |
29 | | #include "common_labels.h" |
30 | | #include "create_data_table.h" |
31 | | #include "stat_bench/measurer/measurement_type.h" |
32 | | #include "stat_bench/param/parameter_name.h" |
33 | | #include "stat_bench/util/utf8_string.h" |
34 | | |
35 | | namespace stat_bench { |
36 | | namespace plots { |
37 | | |
38 | 17 | auto SamplesLinePlot::name_for_file() const -> const util::Utf8String& { |
39 | 17 | return name_for_file_; |
40 | 17 | } |
41 | | |
42 | | void SamplesLinePlot::write(const measurer::MeasurementType& measurement_type, |
43 | | const BenchmarkGroupName& group_name, |
44 | | const std::vector<measurer::Measurement>& measurements, |
45 | 18 | const std::string& file_path) { |
46 | 18 | (void)group_name; |
47 | | |
48 | 18 | const auto& title = measurement_type.str(); |
49 | | |
50 | 18 | const auto data_table = create_data_table_with_all_time(measurements, {}); |
51 | 18 | auto figure = plotly_plotter::figure_builders::line(data_table) |
52 | 18 | .x(sample_index_label) |
53 | 18 | .y(time_label) |
54 | 18 | .group(case_name_label) |
55 | 18 | .log_y(true) |
56 | 18 | .create(); |
57 | 18 | figure.title(title.str()); |
58 | 18 | plotly_plotter::write_html(file_path, figure); |
59 | 18 | } |
60 | | |
61 | | } // namespace plots |
62 | | } // namespace stat_bench |