Writing Custom Main Function#

Runner#

class Runner#

Class of runners of benchmarks.

Public Functions

explicit Runner(bench_impl::BenchmarkCaseRegistry &registry = bench_impl::BenchmarkCaseRegistry::instance())#

Constructor.

Parameters:

registry[in] Registry of benchmarks.

explicit Runner(const Config &config, bench_impl::BenchmarkCaseRegistry &registry = bench_impl::BenchmarkCaseRegistry::instance())#

Constructor.

Parameters:
  • config[in] Configuration.

  • registry[in] Registry of benchmarks.

inline void add(std::shared_ptr<measurer::IMeasurer> measurer)#

Add a measurer.

Parameters:

measurer[in] Measurer.

inline void add(std::shared_ptr<reporter::IReporter> reporter)#

Add a reporter.

Parameters:

reporter[in] Reporter.

void run() const#

Run benchmarks.

Benchmark Registry#

class BenchmarkCaseRegistry#

Class of registry of cases of benchmarks.

Public Functions

BenchmarkCaseRegistry() = default#

Constructor.

void add(std::shared_ptr<IBenchmarkCase> bench_case)#

Add a case.

Parameters:

bench_case[in] Case.

Public Static Functions

static BenchmarkCaseRegistry &instance()#

Get an instance of the registry.

Returns:

Reference to the instance.

Reporter#

class IReporter#

Interface of reporters.

Subclassed by stat_bench::reporter::ConsoleReporter, stat_bench::reporter::DataFileReporterBase, stat_bench::reporter::PlotReporter

Public Functions

virtual ~IReporter() = default#

Destructor.

virtual void case_finished(const BenchmarkFullName &case_info) = 0#

Finished a case of a benchmark.

Parameters:

case_info[in] Information.

virtual void case_starts(const BenchmarkFullName &case_info) = 0#

Start a case of a benchmark.

Parameters:

case_info[in] Information.

virtual void experiment_finished(const clock::SystemTimePoint &time_stamp) = 0#

Finished an experiment.

Parameters:

time_stamp[in] Time stamp.

virtual void experiment_starts(const clock::SystemTimePoint &time_stamp) = 0#

Start an experiment.

Parameters:

time_stamp[in] Time stamp.

virtual void group_finished(const BenchmarkGroupName &name) = 0#

Finished a group of benchmarks.

Parameters:

name[in] Group name.

virtual void group_starts(const BenchmarkGroupName &name, const bench_impl::BenchmarkGroupConfig &config) = 0#

Start a group of benchmarks.

Parameters:
  • name[in] Group name.

  • config[in] Configuration.

virtual void measurement_failed(const BenchmarkFullName &case_info, const BenchmarkCondition &cond, const std::exception_ptr &error) = 0#

Failed a measurement.

Parameters:
  • case_info[in] Information of the case.

  • cond[in] Condition.

  • error[in] Error.

virtual void measurement_succeeded(const measurer::Measurement &measurement) = 0#

Successfully finished a measurement.

Parameters:

measurement[in] Measurement.

virtual void measurer_finished(const measurer::MeasurerName &name) = 0#

Finished benchmarks using a measurer.

Parameters:

name[in] Measurer name.

virtual void measurer_starts(const measurer::MeasurerName &name) = 0#

Start benchmarks using a measurer.

Parameters:

name[in] Measurer name.

class BenchmarkFullName#

Class of information of cases in benchmarks.

Public Functions

inline const BenchmarkCaseName &case_name() const noexcept#

Get the name of the case in the benchmark.

Returns:

Name of the case in the benchmark.

inline const BenchmarkGroupName &group_name() const noexcept#

Get the name of the group of cases.

Returns:

Name of the group of cases.

class BenchmarkCondition#

Class of conditions of benchmarks.

Public Functions

inline const param::ParameterDict &params() const noexcept#

Get the parameters.

Returns:

Parameters.

inline std::size_t threads() const noexcept#

Get the number of threads.

Returns:

Number of threads.

class ParameterDict#

Class of dictionaries of parameters.

Public Functions

std::unordered_map<util::Utf8String, util::Utf8String> as_string_dict() const#

Get as a dictionary of string values.

Returns:

Dictionary.

fmt::format_context::iterator format_to(fmt::format_context::iterator out) const#

Format to string.

Parameters:

out[in] Output iterator to write the formatted string.

Returns:

Output iterator after formatting.

template<typename T>
inline const T &get(const ParameterName &param_name) const#

Get a parameter value.

Template Parameters:

T – Type of the value.

Parameters:

param_name[in] Parameter name.

Returns:

Value.

class Measurement#

Class of data of measurements.

Public Functions

inline const BenchmarkFullName &case_info() const noexcept#

Get the information of the case.

Returns:

Information of the case.

inline const BenchmarkCondition &cond() const noexcept#

Get the condition.

Returns:

Condition.

inline const std::vector<std::pair<CustomOutputName, double>> &custom_outputs() const noexcept#

Get the custom outputs without statistics.

Returns:

Custom outputs without statistics.

inline const std::vector<stat::Statistics> &custom_stat() const noexcept#

Get the statistics of custom outputs.

Returns:

Statistics of custom outputs.

inline const std::vector<std::shared_ptr<stat::CustomStatOutput>> &custom_stat_outputs() const noexcept#

Get the custom outputs with statistics.

Returns:

Custom outputs with statistics.

inline const std::vector<std::vector<clock::Duration>> &durations() const noexcept#

Get the measured durations.

Note

Duration of iterations in each sample is measured per thread.

Returns:

Measured durations.

inline const stat::Statistics &durations_stat() const noexcept#

Get the statistics of durations.

Returns:

Statistics of durations.

inline const std::size_t &iterations() const noexcept#

Get the number of iterations.

Returns:

Number of iterations.

inline const MeasurerName &measurer_name() const noexcept#

Get the name of the measurer.

Returns:

Name of the measurer.

inline const std::size_t &samples() const noexcept#

Get the number of samples.

Returns:

Number of samples.

class Statistics#

Class to calculate statistics.

Public Functions

inline double max() const noexcept#

Get the max.

Returns:

Max.

inline double mean() const noexcept#

Get the mean.

Returns:

Mean.

inline double min() const noexcept#

Get the min.

Returns:

Min.

inline const std::vector<double> &sorted_samples() const noexcept#

Get the sorted samples.

Returns:

Sorted samples.

inline double standard_deviation() const noexcept#

Get the standard deviation.

Returns:

Standard deviation.

inline const std::vector<double> &unsorted_samples() const noexcept#

Get the unsorted samples.

Returns:

Unsorted samples.

inline double variance() const noexcept#

Get the variance.

Returns:

Variance.

class SystemTimePoint#

Class of time points of system clocks.

class Duration#

Class of durations.

Public Functions

inline explicit Duration(double seconds) noexcept#

Constructor.

Parameters:

seconds[in] Number of seconds.

inline double seconds() const noexcept#

Get the number of seconds.

Returns:

Number of seconds.