CppBenchmark  1.0.4.0
C++ Benchmark Library
Public Member Functions | List of all members
CppBenchmark::Phase Class Referenceabstract

Benchmark phase base class. More...

#include <phase.h>

Inheritance diagram for CppBenchmark::Phase:
CppBenchmark::Context CppBenchmark::PhaseCore CppBenchmark::PhaseScope CppBenchmark::ContextPC CppBenchmark::ContextThreads

Public Member Functions

 Phase () noexcept=default
 
 Phase (const Phase &)=default
 
 Phase (Phase &&) noexcept=default
 
virtual ~Phase ()=default
 
Phaseoperator= (const Phase &)=default
 
Phaseoperator= (Phase &&) noexcept=default
 
virtual const std::string & name () const noexcept=0
 Get phase name. More...
 
virtual const PhaseMetricsmetrics () const noexcept=0
 Get phase metrics. More...
 
virtual std::shared_ptr< PhaseStartPhase (const std::string &phase)=0
 Start a new sub-phase with a given name in a single-thread environment. More...
 
virtual std::shared_ptr< PhaseStartPhaseThreadSafe (const std::string &phase)=0
 Start a new sub-phase with a given name in a multi-thread environment. More...
 
virtual void StopPhase ()=0
 Stop measurement of the current phase. More...
 
virtual std::shared_ptr< PhaseScopeScopePhase (const std::string &phase)=0
 Start a new sub-phase with a given name in a single-thread environment and wrap it in a PhaseScope. More...
 
virtual std::shared_ptr< PhaseScopeScopePhaseThreadSafe (const std::string &phase)=0
 Start a new sub-phase with a given name in a multi-thread environment and wrap it in a PhaseScope. More...
 

Detailed Description

Benchmark phase base class.

Provides interface to start a new sub-phase, stop the current phase, create PhaseScope and access to the current phase name and metrics.

Definition at line 25 of file phase.h.

Constructor & Destructor Documentation

◆ Phase() [1/3]

CppBenchmark::Phase::Phase ( )
defaultnoexcept

◆ Phase() [2/3]

CppBenchmark::Phase::Phase ( const Phase )
default

◆ Phase() [3/3]

CppBenchmark::Phase::Phase ( Phase &&  )
defaultnoexcept

◆ ~Phase()

virtual CppBenchmark::Phase::~Phase ( )
virtualdefault

Member Function Documentation

◆ metrics()

virtual const PhaseMetrics& CppBenchmark::Phase::metrics ( ) const
pure virtualnoexcept

◆ name()

virtual const std::string& CppBenchmark::Phase::name ( ) const
pure virtualnoexcept

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ ScopePhase()

virtual std::shared_ptr<PhaseScope> CppBenchmark::Phase::ScopePhase ( const std::string &  phase)
pure virtual

Start a new sub-phase with a given name in a single-thread environment and wrap it in a PhaseScope.

Please note the method is not thread-safe and should not be called in multi-thread environment!

Parameters
phase- Sub-phase name
Returns
Shared pointer to the required benchmark sub-phase scope wrapper

Implemented in CppBenchmark::PhaseScope, CppBenchmark::PhaseCore, and CppBenchmark::Context.

◆ ScopePhaseThreadSafe()

virtual std::shared_ptr<PhaseScope> CppBenchmark::Phase::ScopePhaseThreadSafe ( const std::string &  phase)
pure virtual

Start a new sub-phase with a given name in a multi-thread environment and wrap it in a PhaseScope.

Please note the method is thread-safe and might be called in multi-thread environment!

Parameters
phase- Sub-phase name
Returns
Shared pointer to the required thread-safe benchmark sub-phase scope wrapper

Implemented in CppBenchmark::PhaseScope, CppBenchmark::PhaseCore, and CppBenchmark::Context.

◆ StartPhase()

virtual std::shared_ptr<Phase> CppBenchmark::Phase::StartPhase ( const std::string &  phase)
pure virtual

Start a new sub-phase with a given name in a single-thread environment.

This method will create or get existent sub-phase with a given name, start benchmark measurement and return it as a shared pointer. Please note the method is not thread-safe and should not be called in multi-thread environment!

Parameters
phase- Sub-phase name
Returns
Shared pointer to the required benchmark sub-phase

Implemented in CppBenchmark::PhaseScope, CppBenchmark::PhaseCore, and CppBenchmark::Context.

◆ StartPhaseThreadSafe()

virtual std::shared_ptr<Phase> CppBenchmark::Phase::StartPhaseThreadSafe ( const std::string &  phase)
pure virtual

Start a new sub-phase with a given name in a multi-thread environment.

This method will create or get existent sub-phase with a given name, start benchmark measurement and return it as a shared pointer. Please note the method is thread-safe and might be called in multi-thread environment!

Parameters
phase- Sub-phase name
Returns
Shared pointer to the thread safe benchmark sub-phase

Implemented in CppBenchmark::PhaseScope, CppBenchmark::PhaseCore, and CppBenchmark::Context.

◆ StopPhase()

virtual void CppBenchmark::Phase::StopPhase ( )
pure virtual

Stop measurement of the current phase.

Implemented in CppBenchmark::PhaseScope, CppBenchmark::PhaseCore, and CppBenchmark::Context.


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