9 #ifndef CPPBENCHMARK_PHASE_SCOPE_H
10 #define CPPBENCHMARK_PHASE_SCOPE_H
28 explicit PhaseScope(
const std::shared_ptr<Phase>& phase) noexcept : _phase(phase) {}
38 explicit operator
bool() const noexcept
39 {
return _phase ? true :
false; }
42 const std::string&
name() const noexcept
override
43 {
return _phase ? _phase->name() : EMPTY_NAME; }
45 {
return _phase ? _phase->metrics() : EMPTY_METRICS; }
46 std::shared_ptr<Phase>
StartPhase(
const std::string& phase)
override;
49 std::shared_ptr<PhaseScope>
ScopePhase(
const std::string& phase)
override;
53 std::shared_ptr<Phase> _phase;
55 static const std::string EMPTY_NAME;
Benchmark phase base class.
PhaseScope(const std::shared_ptr< Phase > &phase) noexcept
Create benchmark phase scope and attach existing benchmark phase to it.
PhaseScope(const PhaseScope &) noexcept=default
const std::string & name() const noexcept override
Get phase name.
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.
std::shared_ptr< Phase > StartPhaseThreadSafe(const std::string &phase) override
Start a new sub-phase with a given name in a multi-thread environment.
std::shared_ptr< Phase > StartPhase(const std::string &phase) override
Start a new sub-phase with a given name in a single-thread environment.
void StopPhase() override
Stop measurement of the current phase.
const PhaseMetrics & metrics() const noexcept override
Get phase metrics.
PhaseScope(PhaseScope &&) noexcept=default
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.
C++ Benchmark project definitions.
Benchmark phase base definition.