diff --git a/grapher/include/grapher/utils/json.hpp b/grapher/include/grapher/utils/json.hpp index f738ff8..3f432cb 100644 --- a/grapher/include/grapher/utils/json.hpp +++ b/grapher/include/grapher/utils/json.hpp @@ -17,7 +17,7 @@ namespace grapher { /// For each iteration in entry, returns the sum of the values pointed by /// value_jptr in the events matching the descriptor's predicates. std::vector get_values(benchmark_iteration_t const &iteration, - group_descriptor_t const &descriptor, + std::vector const &predicates, nlohmann::json::json_pointer value_jptr); /// Merges the contents of b into a, with items of a being overwritten if items diff --git a/grapher/lib/grapher/plotters/compare.cpp b/grapher/lib/grapher/plotters/compare.cpp index fd49e28..0bb11bf 100644 --- a/grapher/lib/grapher/plotters/compare.cpp +++ b/grapher/lib/grapher/plotters/compare.cpp @@ -11,6 +11,7 @@ #include "grapher/core.hpp" #include "grapher/plotters/compare.hpp" +#include "grapher/predicates.hpp" #include "grapher/utils/config.hpp" #include "grapher/utils/json.hpp" #include "grapher/utils/plot.hpp" @@ -62,6 +63,9 @@ void plotter_compare_t::plot(benchmark_set_t const &bset, sciplot::Plot plot; apply_config(plot, config); + // Generating predicates + std::vector predicates = get_predicates(descriptor); + for (benchmark_case_t const &bench : bset) { std::vector x_points; std::vector y_points; @@ -77,7 +81,7 @@ void plotter_compare_t::plot(benchmark_set_t const &bset, } std::vector const values = - get_values(iteration, descriptor, value_json_pointer); + get_values(iteration, predicates, value_json_pointer); if (values.empty()) { llvm::errs() << "[WARNING] No event in benchmark " << bench.name diff --git a/grapher/lib/grapher/plotters/stack.cpp b/grapher/lib/grapher/plotters/stack.cpp index 3ee442d..9169a25 100644 --- a/grapher/lib/grapher/plotters/stack.cpp +++ b/grapher/lib/grapher/plotters/stack.cpp @@ -10,6 +10,7 @@ #include "grapher/core.hpp" #include "grapher/plotters/stack.hpp" +#include "grapher/predicates.hpp" #include "grapher/utils/config.hpp" #include "grapher/utils/json.hpp" #include "grapher/utils/plot.hpp" @@ -84,10 +85,12 @@ void plotter_stack_t::plot(benchmark_set_t const &bset, // Storing previous value as we iterate std::string curve_name = descriptor.name; + std::vector predicates = get_predicates(descriptor); + for (std::size_t i = 0; i < bench.iterations.size(); i++) { benchmark_iteration_t const &iteration = bench.iterations[i]; std::vector const values = - get_values(iteration, descriptor, feature_value_jptr); + get_values(iteration, predicates, feature_value_jptr); if (values.empty()) { llvm::errs() << "[ERROR] No event matching descriptor " diff --git a/grapher/lib/grapher/utils/json.cpp b/grapher/lib/grapher/utils/json.cpp index d8d4d82..b774a31 100644 --- a/grapher/lib/grapher/utils/json.cpp +++ b/grapher/lib/grapher/utils/json.cpp @@ -1,23 +1,17 @@ #include "grapher/utils/json.hpp" +#include "grapher/predicates.hpp" +#include "grapher/utils/config.hpp" #include #include #include -#include -#include - -#include #include -#include - -#include "grapher/predicates.hpp" -#include "grapher/utils/config.hpp" namespace grapher { std::vector get_values(benchmark_iteration_t const &iteration, - group_descriptor_t const &descriptor, + std::vector const &predicates, nlohmann::json::json_pointer value_jptr) { std::vector res(iteration.samples.size()); @@ -37,8 +31,6 @@ std::vector get_values(benchmark_iteration_t const &iteration, nlohmann::json::array_t const &events = j["traceEvents"].get_ref(); - std::vector predicates = get_predicates(descriptor); - // Accumulate double val = 0.; for (nlohmann::json const &event : events) {