CppBenchmark 1.0.6.0
C++ Benchmark Library
Loading...
Searching...
No Matches
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
ContextPC & operator= (const ContextPC &) noexcept=default
ContextPC & operator= (ContextPC &&) noexcept=default
int producers () const noexcept
 Benchmark producers count.
int consumers () const noexcept
 Benchmark consumers count.
bool produce_stopped () const noexcept
 Is benchmark produce stopped?
bool consume_stopped () const noexcept
 Is benchmark consume stopped?
void StopProduce () noexcept
 Stop benchmark production.
void StopConsume () noexcept
 Stop benchmark consumption.
std::string description () const override
 Get description of the current benchmark running context.
Public Member Functions inherited from CppBenchmark::Context
 Context ()=delete
 Context (const Context &) noexcept=default
 Context (Context &&) noexcept=default
virtual ~Context () noexcept=default
Context & operator= (const Context &) noexcept=default
Context & operator= (Context &&) noexcept=default
int x () const noexcept
 Benchmark first parameter. Valid only if not negative!
int y () const noexcept
 Benchmark second parameter. Valid only if not negative!
int z () const noexcept
 Benchmark third parameter. Valid only if not negative!
PhaseMetrics & metrics () noexcept
 Benchmark mutable metrics.
bool canceled () const noexcept
 Is benchmark execution canceled?
void Cancel () noexcept
 Cancel benchmark execution.
const std::string & name () const noexcept override
 Get phase name.
const PhaseMetrics & metrics () const noexcept override
 Get phase metrics.
std::shared_ptr< Phase > StartPhase (const std::string &phase) override
 Start a new sub-phase with a given name in a single-thread environment.
std::shared_ptr< Phase > StartPhaseThreadSafe (const std::string &phase) override
 Start a new sub-phase with a given name in a multi-thread environment.
void StopPhase () override
 Stop measurement of the current phase.
std::shared_ptr< PhaseScope > ScopePhase (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.
std::shared_ptr< PhaseScope > ScopePhaseThreadSafe (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.
Public Member Functions inherited from CppBenchmark::Phase
 Phase () noexcept=default
 Phase (const Phase &)=default
 Phase (Phase &&) noexcept=default
virtual ~Phase ()=default
Phase & operator= (const Phase &)=default
Phase & operator= (Phase &&) noexcept=default

Protected Member Functions

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

Protected Attributes

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

Friends

class BenchmarkPC

Detailed Description

Benchmark producer/consumer running context.

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

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

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