CppBenchmark  1.0.4.0
C++ Benchmark Library
Public Member Functions | Friends | List of all members
CppBenchmark::Settings Class Reference

Benchmark settings. More...

#include <settings.h>

Inheritance diagram for CppBenchmark::Settings:
CppBenchmark::SettingsPC CppBenchmark::SettingsThreads

Public Member Functions

 Settings ()
 Initialize settings with the default benchmark duration (5 seconds) More...
 
 Settings (int64_t operations)
 Initialize settings with the given count of operations. More...
 
 Settings (const Settings &)=default
 
 Settings (Settings &&) noexcept=default
 
 ~Settings ()=default
 
Settingsoperator= (const Settings &)=default
 
Settingsoperator= (Settings &&) noexcept=default
 
int attempts () const noexcept
 Get count of independent benchmark attempts. More...
 
bool infinite () const noexcept
 Is benchmark running with infinite count of operations (until cancel)? More...
 
int64_t duration () const noexcept
 Get benchmark duration in milliseconds. More...
 
int64_t operations () const noexcept
 Get count of operations. More...
 
const std::vector< int > & threads () const noexcept
 Get collection of independent threads counts in a benchmark plan. More...
 
const std::vector< std::tuple< int, int > > & pc () const noexcept
 Get collection of independent producers/consumers counts in a benchmark plan. More...
 
const std::vector< std::tuple< int, int, int > > & params () const noexcept
 Get collection of independent parameters in a benchmark plan. More...
 
const std::tuple< int64_t, int64_t, int > & latency () const noexcept
 Get latency parameters. More...
 
bool latency_auto () const noexcept
 Get automatic latency update flag. More...
 
SettingsAttempts (int attempts)
 Set independent benchmark attempts. More...
 
SettingsInfinite ()
 Set infinite benchmark operations flag. More...
 
SettingsDuration (int64_t duration)
 Set benchmark duration in seconds. More...
 
SettingsOperations (int64_t operations)
 Set count of operations. More...
 
SettingsThreads (int threads)
 Add new threads count to the benchmark running plan. More...
 
SettingsThreadsRange (int from, int to)
 Add new threads range to the benchmark running plan. More...
 
SettingsThreadsRange (int from, int to, const std::function< int(int, int, int &)> &selector)
 Add new threads range to the benchmark running plan using given selector function. More...
 
SettingsPC (int producers, int consumers)
 Add new producers/consumers count to the benchmark running plan. More...
 
SettingsPCRange (int producers_from, int producers_to, int consumers_from, int consumers_to)
 Add new producers/consumers range to the benchmark running plan. More...
 
SettingsPCRange (int producers_from, int producers_to, const std::function< int(int, int, int &)> &producers_selector, int consumers_from, int consumers_to, const std::function< int(int, int, int &)> &consumers_selector)
 Add new producers/consumers range to the benchmark running plan using given selector functions. More...
 
SettingsParam (int value)
 Add new single parameter to the benchmark running plan. More...
 
SettingsParamRange (int from, int to)
 Add new single parameter range to the benchmark running plan. More...
 
SettingsParamRange (int from, int to, const std::function< int(int, int, int &)> &selector)
 Add new single parameter range to the benchmark running plan using given selector function. More...
 
SettingsPair (int value1, int value2)
 Add new parameters pair to the benchmark running plan. More...
 
SettingsPairRange (int from1, int to1, int from2, int to2)
 Add new parameters pairs range to the benchmark running plan. More...
 
SettingsPairRange (int from1, int to1, const std::function< int(int, int, int &)> &selector1, int from2, int to2, const std::function< int(int, int, int &)> &selector2)
 Add new parameters pairs range to the benchmark running plan using given selector functions. More...
 
SettingsTriple (int value1, int value2, int value3)
 Add new parameters triple to the benchmark running plan. More...
 
SettingsTripleRange (int from1, int to1, int from2, int to2, int from3, int to3)
 Add new parameters triple range to the benchmark running plan. More...
 
SettingsTripleRange (int from1, int to1, const std::function< int(int, int, int &)> &selector1, int from2, int to2, const std::function< int(int, int, int &)> &selector2, int from3, int to3, const std::function< int(int, int, int &)> &selector3)
 Add new parameters triple range to the benchmark running plan using given selector functions. More...
 
SettingsLatency (int64_t lowest, int64_t highest, int significant, bool automatic=true)
 Set latency histogram parameters. More...
 

Friends

class Benchmark
 
class BenchmarkPC
 
class BenchmarkThreads
 

Detailed Description

Benchmark settings.

Provides interface to all benchmark settings:

All settings can be configured using fluent syntax.

Examples
fwrite.cpp, mpmc.cpp, mpsc.cpp, spsc.cpp, and threads.cpp.

Definition at line 31 of file settings.h.

Constructor & Destructor Documentation

◆ Settings() [1/4]

CppBenchmark::Settings::Settings ( )

Initialize settings with the default benchmark duration (5 seconds)

Definition at line 13 of file settings.cpp.

◆ Settings() [2/4]

CppBenchmark::Settings::Settings ( int64_t  operations)

Initialize settings with the given count of operations.

Parameters
operations- Count of operations

Definition at line 24 of file settings.cpp.

◆ Settings() [3/4]

CppBenchmark::Settings::Settings ( const Settings )
default

◆ Settings() [4/4]

CppBenchmark::Settings::Settings ( Settings &&  )
defaultnoexcept

◆ ~Settings()

CppBenchmark::Settings::~Settings ( )
default

Member Function Documentation

◆ attempts()

int CppBenchmark::Settings::attempts ( ) const
inlinenoexcept

Get count of independent benchmark attempts.

Definition at line 53 of file settings.h.

◆ Attempts()

Settings & CppBenchmark::Settings::Attempts ( int  attempts)

Set independent benchmark attempts.

Benchmark will be launched in several independent attempts. Best attempt with the lowest total execution time will be chosen as result one.

Parameters
attempts- Independent benchmark attempts (must be positive)

Definition at line 30 of file settings.cpp.

◆ duration()

int64_t CppBenchmark::Settings::duration ( ) const
inlinenoexcept

Get benchmark duration in milliseconds.

Definition at line 57 of file settings.h.

◆ Duration()

Settings & CppBenchmark::Settings::Duration ( int64_t  duration)

Set benchmark duration in seconds.

Parameters
duration- Benchmark duration in seconds (must be positive)
Returns
Reference to the current settings instance

Definition at line 52 of file settings.cpp.

◆ Infinite()

Settings & CppBenchmark::Settings::Infinite ( )

Set infinite benchmark operations flag.

Benchmark will be launched in infinite operations loop until Context.Cancel() method is called.

Examples
mpmc.cpp, mpsc.cpp, and spsc.cpp.

Definition at line 36 of file settings.cpp.

◆ infinite()

bool CppBenchmark::Settings::infinite ( ) const
inlinenoexcept

Is benchmark running with infinite count of operations (until cancel)?

Definition at line 55 of file settings.h.

◆ latency()

const std::tuple<int64_t, int64_t, int>& CppBenchmark::Settings::latency ( ) const
inlinenoexcept

Get latency parameters.

Definition at line 67 of file settings.h.

◆ Latency()

Settings & CppBenchmark::Settings::Latency ( int64_t  lowest,
int64_t  highest,
int  significant,
bool  automatic = true 
)

Set latency histogram parameters.

Parameters
lowest- The smallest possible value to be put into the histogram
highest- The largest possible value to be put into the histogram
significant- Number of significant figures
automatic- Automatic latency update (default is true)
Returns
Reference to the current settings instance

Definition at line 333 of file settings.cpp.

◆ latency_auto()

bool CppBenchmark::Settings::latency_auto ( ) const
inlinenoexcept

Get automatic latency update flag.

Definition at line 69 of file settings.h.

◆ operations()

int64_t CppBenchmark::Settings::operations ( ) const
inlinenoexcept

Get count of operations.

Definition at line 59 of file settings.h.

◆ Operations()

Settings & CppBenchmark::Settings::Operations ( int64_t  operations)

Set count of operations.

Parameters
operations- Count of operations (must be positive)
Returns
Reference to the current settings instance

Definition at line 44 of file settings.cpp.

◆ operator=() [1/2]

Settings& CppBenchmark::Settings::operator= ( const Settings )
default

◆ operator=() [2/2]

Settings& CppBenchmark::Settings::operator= ( Settings &&  )
defaultnoexcept

◆ Pair()

Settings & CppBenchmark::Settings::Pair ( int  value1,
int  value2 
)

Add new parameters pair to the benchmark running plan.

Parameters
value1- First parameter (must be positive)
value2- Second parameter (must be positive)
Returns
Reference to the current settings instance

Definition at line 200 of file settings.cpp.

◆ PairRange() [1/2]

Settings & CppBenchmark::Settings::PairRange ( int  from1,
int  to1,
const std::function< int(int, int, int &)> &  selector1,
int  from2,
int  to2,
const std::function< int(int, int, int &)> &  selector2 
)

Add new parameters pairs range to the benchmark running plan using given selector functions.

This method will call selector functions with from1 / from2, to1 / to2 and current arguments. Each selector function may change current argument and return result value. If result value is bounds to xxx_from - xxx_to range it will be add to the benchmark running plan. Otherwise selecting process will stop.

Parameters
from1- From range of the first parameter (must be positive)
to1- To range of the first parameter (must be positive)
selector1- Selector function for the first parameter
from2- From range of the second parameter (must be positive)
to2- To range of the second parameter (must be positive)
selector2- Selector function for the second parameter
Returns
Reference to the current settings instance

Definition at line 224 of file settings.cpp.

◆ PairRange() [2/2]

Settings & CppBenchmark::Settings::PairRange ( int  from1,
int  to1,
int  from2,
int  to2 
)

Add new parameters pairs range to the benchmark running plan.

This method will iterate from1, from2 - to1, to2 and add each parameters pair to the benchmark running plan.

Parameters
from1- From range of the first parameter (must be positive)
to1- To range of the first parameter (must be positive)
from2- From range of the second parameter (must be positive)
to2- To range of the second parameter (must be positive)
Returns
Reference to the current settings instance

Definition at line 207 of file settings.cpp.

◆ Param()

Settings & CppBenchmark::Settings::Param ( int  value)

Add new single parameter to the benchmark running plan.

Parameters
value- Single parameter (must be positive)
Returns
Reference to the current settings instance

Definition at line 159 of file settings.cpp.

◆ ParamRange() [1/2]

Settings & CppBenchmark::Settings::ParamRange ( int  from,
int  to 
)

Add new single parameter range to the benchmark running plan.

This method will iterate from - to and add each single parameter value to the benchmark running plan.

Parameters
from- From range of the single parameter (must be positive)
to- To range of the single parameter (must be positive)
Returns
Reference to the current settings instance
Examples
fwrite.cpp.

Definition at line 166 of file settings.cpp.

◆ ParamRange() [2/2]

Settings & CppBenchmark::Settings::ParamRange ( int  from,
int  to,
const std::function< int(int, int, int &)> &  selector 
)

Add new single parameter range to the benchmark running plan using given selector function.

This method will call selector function with from, to and current argument. Selector function may change current argument and return result value. If result value is bounds to from to range it will be add to the benchmark running plan. Otherwise selecting process will stop.

Parameters
from- From range of the single parameter (must be positive)
to- To range of the single parameter (must be positive)
selector- Selector function
Returns
Reference to the current settings instance

Definition at line 179 of file settings.cpp.

◆ params()

const std::vector<std::tuple<int, int, int> >& CppBenchmark::Settings::params ( ) const
inlinenoexcept

Get collection of independent parameters in a benchmark plan.

Definition at line 65 of file settings.h.

◆ pc()

const std::vector<std::tuple<int, int> >& CppBenchmark::Settings::pc ( ) const
inlinenoexcept

Get collection of independent producers/consumers counts in a benchmark plan.

Definition at line 63 of file settings.h.

◆ PC()

Settings & CppBenchmark::Settings::PC ( int  producers,
int  consumers 
)

Add new producers/consumers count to the benchmark running plan.

Parameters
producers- Count of producers (must be positive)
consumers- Count of consumers (must be positive)
Returns
Reference to the current settings instance
Examples
spsc.cpp.

Definition at line 101 of file settings.cpp.

◆ PCRange() [1/2]

Settings & CppBenchmark::Settings::PCRange ( int  producers_from,
int  producers_to,
const std::function< int(int, int, int &)> &  producers_selector,
int  consumers_from,
int  consumers_to,
const std::function< int(int, int, int &)> &  consumers_selector 
)

Add new producers/consumers range to the benchmark running plan using given selector functions.

This method will call selector functions with producers_from / consumers_from, producers_to / consumers_to and current arguments. Each selector function may change current argument and return result value. If result value is bounds to xxx_from - xxx_to range it will be add to the benchmark running plan. Otherwise selecting process will stop.

Parameters
producers_from- From range of producers (must be positive)
producers_to- To range of producers (must be positive)
producers_selector- Producers selector function
consumers_from- From range of consumers (must be positive)
consumers_to- To range of consumers (must be positive)
consumers_selector- Consumers selector function
Returns
Reference to the current settings instance

Definition at line 125 of file settings.cpp.

◆ PCRange() [2/2]

Settings & CppBenchmark::Settings::PCRange ( int  producers_from,
int  producers_to,
int  consumers_from,
int  consumers_to 
)

Add new producers/consumers range to the benchmark running plan.

This method will iterate producers_from, consumers_from - producers_to, consumers_to and add each producers/consumers pair to the benchmark running plan.

Parameters
producers_from- From range of producers (must be positive)
producers_to- To range of producers (must be positive)
consumers_from- From range of consumers (must be positive)
consumers_to- To range of consumers (must be positive)
Returns
Reference to the current settings instance
Examples
mpmc.cpp, and mpsc.cpp.

Definition at line 108 of file settings.cpp.

◆ threads()

const std::vector<int>& CppBenchmark::Settings::threads ( ) const
inlinenoexcept

Get collection of independent threads counts in a benchmark plan.

Definition at line 61 of file settings.h.

◆ Threads()

Settings & CppBenchmark::Settings::Threads ( int  threads)

Add new threads count to the benchmark running plan.

Parameters
threads- Count of running threads (must be positive)
Returns
Reference to the current settings instance

Definition at line 60 of file settings.cpp.

◆ ThreadsRange() [1/2]

Settings & CppBenchmark::Settings::ThreadsRange ( int  from,
int  to 
)

Add new threads range to the benchmark running plan.

This method will iterate from - to and add each threads value to the benchmark running plan.

Parameters
from- From range of running threads (must be positive)
to- To range of running threads (must be positive)
Returns
Reference to the current settings instance
Examples
threads.cpp.

Definition at line 67 of file settings.cpp.

◆ ThreadsRange() [2/2]

Settings & CppBenchmark::Settings::ThreadsRange ( int  from,
int  to,
const std::function< int(int, int, int &)> &  selector 
)

Add new threads range to the benchmark running plan using given selector function.

This method will call selector function with from, to and current argument. Selector function may change current argument and return result value. If result value is bounds to from to range it will be add to the benchmark running plan. Otherwise selecting process will stop.

Parameters
from- From range of running threads (must be positive)
to- To range of running threads (must be positive)
selector- Selector function
Returns
Reference to the current settings instance

Definition at line 80 of file settings.cpp.

◆ Triple()

Settings & CppBenchmark::Settings::Triple ( int  value1,
int  value2,
int  value3 
)

Add new parameters triple to the benchmark running plan.

Parameters
value1- First parameter (must be positive)
value2- Second parameter (must be positive)
value3- Third parameter (must be positive)
Returns
Reference to the current settings instance

Definition at line 258 of file settings.cpp.

◆ TripleRange() [1/2]

Settings & CppBenchmark::Settings::TripleRange ( int  from1,
int  to1,
const std::function< int(int, int, int &)> &  selector1,
int  from2,
int  to2,
const std::function< int(int, int, int &)> &  selector2,
int  from3,
int  to3,
const std::function< int(int, int, int &)> &  selector3 
)

Add new parameters triple range to the benchmark running plan using given selector functions.

This method will call selector functions with from1 / from2 / from3, to1 / to2 / to3 and current arguments. Each selector function may change current argument and return result value. If result value is bounds to xxx_from - xxx_to range it will be add to the benchmark running plan. Otherwise selecting process will stop.

Parameters
from1- From range of the first parameter (must be positive)
to1- To range of the first parameter (must be positive)
selector1- Selector function for the first parameter
from2- From range of the second parameter (must be positive)
to2- To range of the second parameter (must be positive)
selector2- Selector function for the second parameter
from3- From range of the third parameter (must be positive)
to3- To range of the third parameter (must be positive)
selector3- Selector function for the third parameter
Returns
Reference to the current settings instance

Definition at line 286 of file settings.cpp.

◆ TripleRange() [2/2]

Settings & CppBenchmark::Settings::TripleRange ( int  from1,
int  to1,
int  from2,
int  to2,
int  from3,
int  to3 
)

Add new parameters triple range to the benchmark running plan.

This method will iterate from1, from2, from3 - to1, to2, to3 and add each parameters triple to the benchmark running plan.

Parameters
from1- From range of the first parameter (must be positive)
to1- To range of the first parameter (must be positive)
from2- From range of the second parameter (must be positive)
to2- To range of the second parameter (must be positive)
from3- From range of the third parameter (must be positive)
to3- To range of the third parameter (must be positive)
Returns
Reference to the current settings instance

Definition at line 265 of file settings.cpp.

Friends And Related Function Documentation

◆ Benchmark

friend class Benchmark
friend

Definition at line 33 of file settings.h.

◆ BenchmarkPC

friend class BenchmarkPC
friend

Definition at line 34 of file settings.h.

◆ BenchmarkThreads

friend class BenchmarkThreads
friend

Definition at line 35 of file settings.h.


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