cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
stat_bench::InvocationContext Class Reference

Class of context of invocations of benchmarks. More...

#include <stat_bench/invocation_context.h>

+ Collaboration diagram for stat_bench::InvocationContext:

Public Member Functions

 InvocationContext (BenchmarkCondition cond, std::size_t iterations, std::size_t samples, std::size_t warming_up_samples)
 Constructor.
 
 InvocationContext (const InvocationContext &)=delete
 
 InvocationContext (InvocationContext &&)=delete
 
 ~InvocationContext ()=default
 Destructor.
 
void add_custom_output (const CustomOutputName &name, double value)
 Add a custom output without statistics.
 
void add_custom_output (std::string name, double value)
 Add a custom output without statistics.
 
auto add_custom_stat (const CustomOutputName &name, stat::CustomOutputAnalysisType analysis_type=stat::CustomOutputAnalysisType::mean) -> std::shared_ptr< stat::CustomStatOutput >
 Add a custom output with statistics.
 
auto add_custom_stat (std::string name, stat::CustomOutputAnalysisType analysis_type=stat::CustomOutputAnalysisType::mean) -> std::shared_ptr< stat::CustomStatOutput >
 Add a custom output with statistics.
 
auto custom_outputs () const noexcept -> const std::vector< std::pair< CustomOutputName, double > > &
 Get the custom outputs without statistics.
 
auto custom_stat_outputs () const noexcept -> const std::vector< std::shared_ptr< stat::CustomStatOutput > > &
 Get the custom outputs with statistics.
 
auto durations () const noexcept -> const std::vector< std::vector< clock::Duration > > &
 Get the measured durations.
 
template<typename T>
auto get_param (const param::ParameterName &param_name) const -> const T &
 Get a parameter.
 
template<typename T>
auto get_param (std::string param_name) const -> const T &
 Get a parameter.
 
auto iterations () const noexcept -> std::size_t
 Get the number of iterations.
 
template<typename Func>
void measure (const Func &func)
 Measure time.
 
auto operator= (const InvocationContext &)=delete
 
auto operator= (InvocationContext &&)=delete
 
auto samples () const noexcept -> std::size_t
 Get the number of samples.
 
auto threads () const noexcept -> std::size_t
 Get the number of threads.
 

Detailed Description

Class of context of invocations of benchmarks.

Definition at line 40 of file invocation_context.h.

Constructor & Destructor Documentation

◆ InvocationContext()

stat_bench::InvocationContext::InvocationContext ( BenchmarkCondition cond,
std::size_t iterations,
std::size_t samples,
std::size_t warming_up_samples )
inline

Constructor.

Parameters
[in]condCondition.
[in]iterationsNumber of iterations.
[in]samplesNumber of samples (including warming up).
[in]warming_up_samplesNumber of samples for warming up.

Definition at line 50 of file invocation_context.h.

Member Function Documentation

◆ add_custom_output() [1/2]

void stat_bench::InvocationContext::add_custom_output ( const CustomOutputName & name,
double value )
inline

Add a custom output without statistics.

Parameters
[in]nameName.
[in]valueOutput value.

Definition at line 158 of file invocation_context.h.

◆ add_custom_output() [2/2]

void stat_bench::InvocationContext::add_custom_output ( std::string name,
double value )
inline

Add a custom output without statistics.

Parameters
[in]nameName.
[in]valueOutput value.

Definition at line 168 of file invocation_context.h.

◆ add_custom_stat() [1/2]

auto stat_bench::InvocationContext::add_custom_stat ( const CustomOutputName & name,
stat::CustomOutputAnalysisType analysis_type = stat::CustomOutputAnalysisType::mean ) -> std::shared_ptr<stat::CustomStatOutput>
inlinenodiscard

Add a custom output with statistics.

Parameters
[in]nameName.
[in]analysis_typeType of analysis.
Returns
Object to add output values.

Definition at line 126 of file invocation_context.h.

◆ add_custom_stat() [2/2]

auto stat_bench::InvocationContext::add_custom_stat ( std::string name,
stat::CustomOutputAnalysisType analysis_type = stat::CustomOutputAnalysisType::mean ) -> std::shared_ptr<stat::CustomStatOutput>
inlinenodiscard

Add a custom output with statistics.

Parameters
[in]nameName.
[in]analysis_typeType of analysis.
Returns
Object to add output values.

Definition at line 144 of file invocation_context.h.

◆ custom_outputs()

auto stat_bench::InvocationContext::custom_outputs ( ) const -> const std::vector<std::pair<CustomOutputName, double>>&
inlinenodiscardnoexcept

Get the custom outputs without statistics.

Returns
Custom outputs without statistics.

Definition at line 212 of file invocation_context.h.

◆ custom_stat_outputs()

auto stat_bench::InvocationContext::custom_stat_outputs ( ) const -> const std::vector<std::shared_ptr<stat::CustomStatOutput>>&
inlinenodiscardnoexcept

Get the custom outputs with statistics.

Returns
Custom outputs with statistics.

Definition at line 202 of file invocation_context.h.

◆ durations()

auto stat_bench::InvocationContext::durations ( ) const -> const std::vector<std::vector<clock::Duration>>&
inlinenodiscardnoexcept

Get the measured durations.

Note
Duration of iterations in each sample is measured per thread.
Returns
Durations.

Definition at line 192 of file invocation_context.h.

◆ get_param() [1/2]

template<typename T>
auto stat_bench::InvocationContext::get_param ( const param::ParameterName & param_name) const -> const T&
inlinenodiscard

Get a parameter.

Template Parameters
TType of the parameter value.
Parameters
[in]param_nameParameter name.
Returns
Parameter value.

Definition at line 102 of file invocation_context.h.

◆ get_param() [2/2]

template<typename T>
auto stat_bench::InvocationContext::get_param ( std::string param_name) const -> const T&
inlinenodiscard

Get a parameter.

Template Parameters
TType of the parameter value.
Parameters
[in]param_nameParameter name.
Returns
Parameter value.

Definition at line 115 of file invocation_context.h.

◆ iterations()

auto stat_bench::InvocationContext::iterations ( ) const -> std::size_t
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 81 of file invocation_context.h.

◆ measure()

template<typename Func>
void stat_bench::InvocationContext::measure ( const Func & func)
inline

Measure time.

Template Parameters
FuncType of function.
Parameters
[in]funcFunction.

Definition at line 179 of file invocation_context.h.

◆ samples()

auto stat_bench::InvocationContext::samples ( ) const -> std::size_t
inlinenodiscardnoexcept

Get the number of samples.

Returns
Number of samples.

Definition at line 90 of file invocation_context.h.

◆ threads()

auto stat_bench::InvocationContext::threads ( ) const -> std::size_t
inlinenodiscardnoexcept

Get the number of threads.

Returns
Number of threads.

Definition at line 72 of file invocation_context.h.


The documentation for this class was generated from the following file: