CppBenchmark 1.0.6.0
C++ Benchmark Library
Loading...
Searching...
No Matches
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).
 Settings (int64_t operations)
 Initialize settings with the given count of operations.
 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.
bool infinite () const noexcept
 Is benchmark running with infinite count of operations (until cancel)?
int64_t duration () const noexcept
 Get benchmark duration in milliseconds.
int64_t operations () const noexcept
 Get count of operations.
const std::vector< int > & threads () const noexcept
 Get collection of independent threads counts in a benchmark plan.
const std::vector< std::tuple< int, int > > & pc () const noexcept
 Get collection of independent producers/consumers counts in a benchmark plan.
const std::vector< std::tuple< int, int, int > > & params () const noexcept
 Get collection of independent parameters in a benchmark plan.
const std::tuple< int64_t, int64_t, int > & latency () const noexcept
 Get latency parameters.
bool latency_auto () const noexcept
 Get automatic latency update flag.
SettingsAttempts (int attempts)
 Set independent benchmark attempts.
SettingsInfinite ()
 Set infinite benchmark operations flag.
SettingsDuration (int64_t duration)
 Set benchmark duration in seconds.
SettingsOperations (int64_t operations)
 Set count of operations.
SettingsThreads (int threads)
 Add new threads count to the benchmark running plan.
SettingsThreadsRange (int from, int to)
 Add new threads range to the benchmark running plan.
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.
SettingsPC (int producers, int consumers)
 Add new producers/consumers count to the benchmark running plan.
SettingsPCRange (int producers_from, int producers_to, int consumers_from, int consumers_to)
 Add new producers/consumers range to the benchmark running plan.
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.
SettingsParam (int value)
 Add new single parameter to the benchmark running plan.
SettingsParamRange (int from, int to)
 Add new single parameter range to the benchmark running plan.
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.
SettingsPair (int value1, int value2)
 Add new parameters pair to the benchmark running plan.
SettingsPairRange (int from1, int to1, int from2, int to2)
 Add new parameters pairs range to the benchmark running plan.
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.
SettingsTriple (int value1, int value2, int value3)
 Add new parameters triple to the benchmark running plan.
SettingsTripleRange (int from1, int to1, int from2, int to2, int from3, int to3)
 Add new parameters triple range to the benchmark running plan.
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.
SettingsLatency (int64_t lowest, int64_t highest, int significant, bool automatic=true)
 Set latency histogram parameters.

Friends

class Benchmark
class BenchmarkPC
class BenchmarkThreads

Detailed Description

Benchmark settings.

Provides interface to all benchmark settings:

  • Independent benchmark attempts (default is 5)
  • Benchmark duration in seconds (default is 5)
  • Count of operations (default is 0)
  • Add count of running threads to the benchmark running plan
  • Add count of producers/consumers to the benchmark running plan
  • Add parameters (single, pair, triple) to the benchmark running plan

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()

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.

◆ attempts()

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

Get count of independent benchmark attempts.

Definition at line 53 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.

◆ duration()

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

Get benchmark duration in milliseconds.

Definition at line 57 of file settings.h.

◆ 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()

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()

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_auto()

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

Get automatic latency update flag.

Definition at line 69 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.

◆ operations()

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

Get count of operations.

Definition at line 59 of file settings.h.

◆ 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()

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.

◆ 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.

◆ 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()

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.

◆ 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.

◆ 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.

◆ 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: