32#include <fmt/format.h>
52void print_line(std::FILE* file,
char c) {
53 constexpr std::size_t line_length = 120;
54 fmt::print(file,
"{}\n", std::string(line_length, c));
63 fmt::print(file_, FMT_STRING(
"cpp-stat-bench {}.{}.{}\n\n"),
67 fmt::print(file_, FMT_STRING(
"Benchmark start at {}\n\n"), time_stamp);
69 fmt::print(file_, FMT_STRING(
"Time resolution: {:.3e} sec.\n\n"),
70 clock::MonotoneTimePoint::resolution().seconds());
72 (void)std::fflush(file_);
77 fmt::print(file_, FMT_STRING(
"Benchmark finished at {}\n"), time_stamp);
78 (void)std::fflush(file_);
82 print_line(file_,
'=');
83 fmt::print(file_, FMT_STRING(
"{}\n"), name);
84 print_line(file_,
'=');
85 fmt::print(file_,
"\n");
86 (void)std::fflush(file_);
96auto format_duration(
double val) -> std::string {
97 constexpr double sec_to_us = 1e+6;
98 constexpr double tol = 1e-4;
100 return fmt::format(FMT_STRING(
"{:.4f}"), val * sec_to_us);
102 return fmt::format(FMT_STRING(
"{}"),
103 fmt::group_digits(
static_cast<std::uint64_t
>(val * sec_to_us)));
109#define CONSOLE_TABLE_FORMAT "{:<58} {:>10} {:>7} {:>9} {:>9} {:>9} "
112#define CONSOLE_TABLE_FORMAT_ERROR "{:<58} {}"
116 fmt::print(file_, FMT_STRING(
">> {}\n"), name);
118 "Time [us]",
"",
"",
"");
120 "Samples",
"Mean",
"Std. Err.",
"Max",
"Custom Outputs (mean)");
121 print_line(file_,
'-');
122 (void)std::fflush(file_);
126 fmt::print(file_,
"\n");
127 (void)std::fflush(file_);
142 if (cond.params().empty()) {
143 return case_info.case_name().str().str();
146 FMT_STRING(
"{} ({}) "), case_info.case_name(), cond.params());
154 format_case_name_with_params(
161 fmt::print(file_, FMT_STRING(
"{}={:.3e}, "),
166 fmt::print(file_, FMT_STRING(
"{}={:.3e}, "), out.first, out.second);
168 fmt::print(file_,
"\n");
169 (void)std::fflush(file_);
175 std::rethrow_exception(error);
176 }
catch (
const std::exception& e) {
177 fmt::print(file_, fmt::fg(fmt::color::red),
179 format_case_name_with_params(case_info, cond), e.what());
181 fmt::print(file_,
"\n");
182 (void)std::fflush(file_);
Definition of BenchmarkCaseName class.
Definition of BenchmarkCondition class.
Definition of BenchmarkFullName class.
Class of conditions of benchmarks.
Class of information of cases in benchmarks.
Class of names of groups of benchmarks.
Class of configuration of a group of cases in benchmarks.
Class of time points of system clocks.
Class of data of measurements.
auto custom_stat() const noexcept -> const std::vector< stat::Statistics > &
Get the statistics of custom outputs.
auto iterations() const noexcept -> const std::size_t &
Get the number of iterations.
auto samples() const noexcept -> const std::size_t &
Get the number of samples.
auto cond() const noexcept -> const BenchmarkCondition &
Get the condition.
auto custom_stat_outputs() const noexcept -> const std::vector< std::shared_ptr< stat::CustomStatOutput > > &
Get the custom outputs with statistics.
auto case_info() const noexcept -> const BenchmarkFullName &
Get the information of the case.
auto durations_stat() const noexcept -> const stat::Statistics &
Get the statistics of durations.
auto custom_outputs() const noexcept -> const std::vector< std::pair< CustomOutputName, double > > &
Get the custom outputs without statistics.
Class of names of measurers.
void group_starts(const BenchmarkGroupName &name, const bench_impl::BenchmarkGroupConfig &config) override
Start a group of benchmarks.
void measurement_succeeded(const measurer::Measurement &measurement) override
Successfully finished a measurement.
void experiment_starts(const clock::SystemTimePoint &time_stamp) override
Start an experiment.
void experiment_finished(const clock::SystemTimePoint &time_stamp) override
Finished an experiment.
void case_starts(const BenchmarkFullName &case_info) override
Start a case of a benchmark.
void measurer_starts(const measurer::MeasurerName &name) override
Start benchmarks using a measurer.
void measurement_failed(const BenchmarkFullName &case_info, const BenchmarkCondition &cond, const std::exception_ptr &error) override
Failed a measurement.
ConsoleReporter(std::FILE *file=stdout)
Constructor.
void measurer_finished(const measurer::MeasurerName &name) override
Finished benchmarks using a measurer.
void group_finished(const BenchmarkGroupName &name) override
Finished a group of benchmarks.
void case_finished(const BenchmarkFullName &case_info) override
Finished a case of a benchmark.
#define CONSOLE_TABLE_FORMAT_ERROR
Format of the table for console output when an error occurs.
#define CONSOLE_TABLE_FORMAT
Format of the table for console output.
Definition of ConsoleReporter class.
Definition of CustomOutputName class.
Definition of CustomStatOutput class.
Definition of Duration class.
Definition of Measurement class.
Definition of classes of monotone clocks.
Namespace of reporters of results of benchmarks.
Namespace of stat_bench source codes.
Definition of ParameterDict class.
Definition of Statistics class.
Definition of Utf8String class.
Definition of macros of versions.
#define STAT_BENCH_VERSION_PATCH
Patch version of cpp-stat-bench project.
#define STAT_BENCH_VERSION_MINOR
Minor version of cpp-stat-bench project.
#define STAT_BENCH_VERSION_MAJOR
Major version of cpp-stat-bench project.