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

Benchmark producer/consumer running context. More...

#include <context_pc.h>

Inheritance diagram for CppBenchmark::ContextPC:
CppBenchmark::Context CppBenchmark::Phase

Public Member Functions

 ContextPC ()=delete
 
 ContextPC (const ContextPC &) noexcept=default
 
 ContextPC (ContextPC &&) noexcept=default
 
virtual ~ContextPC () noexcept=default
 
ContextPCoperator= (const ContextPC &) noexcept=default
 
ContextPCoperator= (ContextPC &&) noexcept=default
 
int producers () const noexcept
 Benchmark producers count. More...
 
int consumers () const noexcept
 Benchmark consumers count. More...
 
bool produce_stopped () const noexcept
 Is benchmark produce stopped? More...
 
bool consume_stopped () const noexcept
 Is benchmark consume stopped? More...
 
void StopProduce () noexcept
 Stop benchmark production. More...
 
void StopConsume () noexcept
 Stop benchmark consumption. More...
 
std::string description () const override
 Get description of the current benchmark running context. More...
 
- Public Member Functions inherited from CppBenchmark::Context
 Context ()=delete
 
 Context (const Context &) noexcept=default
 
 Context (Context &&) noexcept=default
 
virtual ~Context () noexcept=default
 
Contextoperator= (const Context &) noexcept=default
 
Contextoperator= (Context &&) noexcept=default
 
int x () const noexcept
 Benchmark first parameter. Valid only if not negative! More...
 
int y () const noexcept
 Benchmark second parameter. Valid only if not negative! More...
 
int z () const noexcept
 Benchmark third parameter. Valid only if not negative! More...
 
PhaseMetricsmetrics () noexcept
 Benchmark mutable metrics. More...
 
bool canceled () const noexcept
 Is benchmark execution canceled? More...
 
void Cancel () noexcept
 Cancel benchmark execution. More...
 
const std::string & name () const noexcept override
 Get phase name. More...
 
const PhaseMetricsmetrics () const noexcept override
 Get phase metrics. More...
 
std::shared_ptr< PhaseStartPhase (const std::string &phase) override
 Start a new sub-phase with a given name in a single-thread environment. More...
 
std::shared_ptr< PhaseStartPhaseThreadSafe (const std::string &phase) override
 Start a new sub-phase with a given name in a multi-thread environment. More...
 
void StopPhase () override
 Stop measurement of the current phase. More...
 
std::shared_ptr< PhaseScopeScopePhase (const std::string &phase) override
 Start a new sub-phase with a given name in a single-thread environment and wrap it in a PhaseScope. More...
 
std::shared_ptr< PhaseScopeScopePhaseThreadSafe (const std::string &phase) override
 Start a new sub-phase with a given name in a multi-thread environment and wrap it in a PhaseScope. More...
 
- Public Member Functions inherited from CppBenchmark::Phase
 Phase () noexcept=default
 
 Phase (const Phase &)=default
 
 Phase (Phase &&) noexcept=default
 
virtual ~Phase ()=default
 
Phaseoperator= (const Phase &)=default
 
Phaseoperator= (Phase &&) noexcept=default
 

Protected Member Functions

 ContextPC (int producers, int consumers, int x, int y, int z) noexcept
 Create benchmark running context. More...
 
- Protected Member Functions inherited from CppBenchmark::Context
 Context (int x, int y, int z) noexcept
 Create benchmark running context. More...
 

Protected Attributes

int _producers
 Benchmark producers count. More...
 
int _consumers
 Benchmark consumers count. More...
 
std::shared_ptr< std::atomic< bool > > _produce_stopped
 Benchmark produce stopped flag. More...
 
std::shared_ptr< std::atomic< bool > > _consume_stopped
 Benchmark consume stopped flag. More...
 
- Protected Attributes inherited from CppBenchmark::Context
int _x
 Benchmark first parameter. Valid only if not negative! More...
 
int _y
 Benchmark second parameter. Valid only if not negative! More...
 
int _z
 Benchmark third parameter. Valid only if not negative! More...
 
PhaseCore_current
 Current benchmark phase. More...
 
PhaseMetrics_metrics
 Current benchmark metrics. More...
 
std::shared_ptr< std::atomic< bool > > _canceled
 Benchmark canceled flag. More...
 

Friends

class BenchmarkPC
 

Detailed Description

Benchmark producer/consumer running context.

Provides access to the current producer/consumer benchmark context information:

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

Definition at line 26 of file context_pc.h.

Constructor & Destructor Documentation

◆ ContextPC() [1/4]

CppBenchmark::ContextPC::ContextPC ( )
delete

◆ ContextPC() [2/4]

CppBenchmark::ContextPC::ContextPC ( const ContextPC )
defaultnoexcept

◆ ContextPC() [3/4]

CppBenchmark::ContextPC::ContextPC ( ContextPC &&  )
defaultnoexcept

◆ ~ContextPC()

virtual CppBenchmark::ContextPC::~ContextPC ( )
virtualdefaultnoexcept

◆ ContextPC() [4/4]

CppBenchmark::ContextPC::ContextPC ( int  producers,
int  consumers,
int  x,
int  y,
int  z 
)
inlineprotectednoexcept

Create benchmark running context.

Parameters
producers- Benchmark producers count
consumers- Benchmark consumers count
x- Benchmark first parameter
y- Benchmark second parameter
z- Benchmark third parameter

Definition at line 74 of file context_pc.h.

Member Function Documentation

◆ consume_stopped()

bool CppBenchmark::ContextPC::consume_stopped ( ) const
inlinenoexcept

Is benchmark consume stopped?

Definition at line 47 of file context_pc.h.

◆ consumers()

int CppBenchmark::ContextPC::consumers ( ) const
inlinenoexcept

Benchmark consumers count.

Definition at line 42 of file context_pc.h.

◆ description()

std::string CppBenchmark::ContextPC::description ( ) const
overridevirtual

Get description of the current benchmark running context.

Reimplemented from CppBenchmark::Context.

Definition at line 13 of file context_pc.cpp.

◆ operator=() [1/2]

ContextPC& CppBenchmark::ContextPC::operator= ( const ContextPC )
defaultnoexcept

◆ operator=() [2/2]

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

◆ produce_stopped()

bool CppBenchmark::ContextPC::produce_stopped ( ) const
inlinenoexcept

Is benchmark produce stopped?

Definition at line 45 of file context_pc.h.

◆ producers()

int CppBenchmark::ContextPC::producers ( ) const
inlinenoexcept

Benchmark producers count.

Definition at line 40 of file context_pc.h.

◆ StopConsume()

void CppBenchmark::ContextPC::StopConsume ( )
inlinenoexcept

Stop benchmark consumption.

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

Definition at line 51 of file context_pc.h.

◆ StopProduce()

void CppBenchmark::ContextPC::StopProduce ( )
inlinenoexcept

Stop benchmark production.

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

Definition at line 49 of file context_pc.h.

Friends And Related Function Documentation

◆ BenchmarkPC

friend class BenchmarkPC
friend

Definition at line 28 of file context_pc.h.

Member Data Documentation

◆ _consume_stopped

std::shared_ptr<std::atomic<bool> > CppBenchmark::ContextPC::_consume_stopped
protected

Benchmark consume stopped flag.

Definition at line 64 of file context_pc.h.

◆ _consumers

int CppBenchmark::ContextPC::_consumers
protected

Benchmark consumers count.

Definition at line 60 of file context_pc.h.

◆ _produce_stopped

std::shared_ptr<std::atomic<bool> > CppBenchmark::ContextPC::_produce_stopped
protected

Benchmark produce stopped flag.

Definition at line 62 of file context_pc.h.

◆ _producers

int CppBenchmark::ContextPC::_producers
protected

Benchmark producers count.

Definition at line 58 of file context_pc.h.


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