Example of a benchmark with a custom output without statistics.
[[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);
}
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.
auto add_param(const param::ParameterName ¶m_name) -> std::shared_ptr< param::ParameterValueVector< T > >
Add a parameter.
auto current_invocation_context() -> InvocationContext &
Get the current invocation context.