CppBenchmark 1.0.5.0
C++ Benchmark Library
Loading...
Searching...
No Matches
phase_scope.cpp
Go to the documentation of this file.
1
10
11namespace CppBenchmark {
12
13const std::string PhaseScope::EMPTY_NAME("<none>");
14const PhaseMetrics PhaseScope::EMPTY_METRICS;
15
17{
18 if (_phase)
19 {
20 _phase->StopPhase();
21 _phase.reset();
22 }
23}
24
25std::shared_ptr<Phase> PhaseScope::StartPhase(const std::string& phase)
26{
27 return _phase ? _phase->StartPhase(phase) : nullptr;
28}
29
30std::shared_ptr<Phase> PhaseScope::StartPhaseThreadSafe(const std::string& phase)
31{
32 return _phase ? _phase->StartPhaseThreadSafe(phase) : nullptr;
33}
34
36{
37 if (_phase)
38 {
39 _phase->StopPhase();
40 _phase.reset();
41 }
42}
43
44std::shared_ptr<PhaseScope> PhaseScope::ScopePhase(const std::string& phase)
45{
46 return _phase ? _phase->ScopePhase(phase) : nullptr;
47}
48
49std::shared_ptr<PhaseScope> PhaseScope::ScopePhaseThreadSafe(const std::string& phase)
50{
51 return _phase ? _phase->ScopePhaseThreadSafe(phase) : nullptr;
52}
53
54} // namespace CppBenchmark
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.
virtual ~PhaseScope()
Benchmark phase will be stopped on destructing.
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.
Definition barrier.h:15
Benchmark phase scope definition.