diff --git a/grapher/lib/grapher/plotters/compare.cpp b/grapher/lib/grapher/plotters/compare.cpp index 0bfb40c..77d99c0 100644 --- a/grapher/lib/grapher/plotters/compare.cpp +++ b/grapher/lib/grapher/plotters/compare.cpp @@ -52,7 +52,7 @@ void plotter_compare_t::plot(benchmark_set_t const &bset, for (group_descriptor_t const &descriptor : group_descriptors) { // Plot init - sciplot::Plot plot; + sciplot::Plot2D plot; apply_config(plot, config); // Generating predicates diff --git a/grapher/lib/grapher/plotters/compare_by.cpp b/grapher/lib/grapher/plotters/compare_by.cpp index 7dde257..bcb0908 100644 --- a/grapher/lib/grapher/plotters/compare_by.cpp +++ b/grapher/lib/grapher/plotters/compare_by.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -127,7 +128,6 @@ grapher::json_t plotter_compare_by_t::get_default_config() const { void plotter_compare_by_t::plot(benchmark_set_t const &bset, std::filesystem::path const &dest, grapher::json_t const &config) const { - namespace sp = sciplot; namespace fs = std::filesystem; // Config reading @@ -156,9 +156,11 @@ void plotter_compare_by_t::plot(benchmark_set_t const &bset, // Drawing, ie. unwrapping the nested maps and drawing curves + saving plots + std::vector thread_pool; + for (auto const &[key, curve_aggregate] : curve_aggregate_map) { // Plot init - sp::Plot plot; + sciplot::Plot2D plot; apply_config(plot, config); for (auto const &[bench_name, benchmark_curve] : curve_aggregate) { @@ -205,7 +207,14 @@ void plotter_compare_by_t::plot(benchmark_set_t const &bset, } } - save_plot(plot, dest / to_string(key, demangle), config); + // Writing in parallel + thread_pool.emplace_back(&save_plot, std::move(plot), + dest / to_string(key, demangle), config); + } + + // Joining before returning + for (std::thread &t : thread_pool) { + t.join(); } } diff --git a/grapher/lib/grapher/plotters/stack.cpp b/grapher/lib/grapher/plotters/stack.cpp index b6ab8ef..a88b4a8 100644 --- a/grapher/lib/grapher/plotters/stack.cpp +++ b/grapher/lib/grapher/plotters/stack.cpp @@ -6,6 +6,7 @@ #include +#include #include #include "grapher/core.hpp" @@ -40,16 +41,14 @@ void plotter_stack_t::plot(benchmark_set_t const &bset, // Drawing - std::vector plots; + std::vector plots; // Storing max y value for normalization double max_y_val = 0.; /// Draws a stacked curve graph for a given benchmark - auto draw_plot = [&](benchmark_case_t const &bench) -> sciplot::Plot { - namespace sp = sciplot; - - sp::Plot plot; + auto draw_plot = [&](benchmark_case_t const &bench) -> sciplot::Plot2D { + sciplot::Plot2D plot; apply_config(plot, config); // x axis diff --git a/grapher/lib/grapher/utils/json.cpp b/grapher/lib/grapher/utils/json.cpp index f423d07..e5643a8 100644 --- a/grapher/lib/grapher/utils/json.cpp +++ b/grapher/lib/grapher/utils/json.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include namespace grapher { @@ -80,9 +82,9 @@ write_descriptors(std::vector const &descriptors) { grapher::json_t::array_t res; res.reserve(descriptors.size()); - for (group_descriptor_t const &d : descriptors) { - res.push_back(group_descriptor_json(d)); - } + std::transform(descriptors.begin(), descriptors.end(), + std::back_inserter(res), &group_descriptor_json); + return res; } @@ -137,7 +139,7 @@ grapher::json_t merge_into(grapher::json_t a, grapher::json_t const &b) { return a; } -void save_plot(sciplot::Plot const &plot, std::string const &dest, +void save_plot(sciplot::Plot2D const &plot, std::string const &dest, grapher::json_t const &config) { namespace fs = std::filesystem; std::vector plot_file_extensions = config.value( @@ -157,7 +159,7 @@ void save_plot(sciplot::Plot const &plot, std::string const &dest, file_dest.replace_filename(new_filename); } - plot.save(dest + extension); + sciplot::Canvas{{sciplot::Figure{{plot}}}}.save(dest + extension); } }