Example of a benchmark with configurations of plotting.
[[nodiscard]] double approx_exp(double x, int num_terms);
public:
ApproxExpFixture() {
->add(1)
->add(2)
->add(5)
->add(10);
}
};
constexpr double x = 1.0;
const int num_terms =
const double expected = std::exp(x);
const double approx = approx_exp(x, num_terms);
const double error = std::abs(approx - expected);
}
.add_parameter_to_time_line_plot("num_terms")
.add_parameter_to_output_line_plot(
.add_time_to_output_by_parameter_line_plot(
double approx_exp(double x, int num_terms) {
double result = 1.0;
double term = 1.0;
for (int i = 1; i < num_terms; ++i) {
term *= x / i;
result += term;
}
return result;
}
Definition of macros for benchmarks.
#define STAT_BENCH_MAIN
Macro of default main function.
#define STAT_BENCH_MEASURE()
Macro to measure a function.
#define STAT_BENCH_CASE_F(FIXTURE_NAME, GROUP_NAME, CASE_NAME)
Macro to define a case using a fixture.
#define STAT_BENCH_GROUP(GROUP_NAME)
Macro to define and configure a group.
auto add_param(const param::ParameterName ¶m_name) -> std::shared_ptr< param::ParameterValueVector< T > >
Add a parameter.
Class of options for plots.
auto current_invocation_context() -> InvocationContext &
Get the current invocation context.