CppBenchmark  1.0.4.0
C++ Benchmark Library
phase_scope.cpp
Go to the documentation of this file.
1 
10 
11 namespace CppBenchmark {
12 
13 const std::string PhaseScope::EMPTY_NAME("<none>");
14 const PhaseMetrics PhaseScope::EMPTY_METRICS;
15 
17 {
18  if (_phase)
19  {
20  _phase->StopPhase();
21  _phase.reset();
22  }
23 }
24 
25 std::shared_ptr<Phase> PhaseScope::StartPhase(const std::string& phase)
26 {
27  return _phase ? _phase->StartPhase(phase) : nullptr;
28 }
29 
30 std::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 
44 std::shared_ptr<PhaseScope> PhaseScope::ScopePhase(const std::string& phase)
45 {
46  return _phase ? _phase->ScopePhase(phase) : nullptr;
47 }
48 
49 std::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.
Definition: phase_scope.cpp:49
std::shared_ptr< Phase > StartPhaseThreadSafe(const std::string &phase) override
Start a new sub-phase with a given name in a multi-thread environment.
Definition: phase_scope.cpp:30
std::shared_ptr< Phase > StartPhase(const std::string &phase) override
Start a new sub-phase with a given name in a single-thread environment.
Definition: phase_scope.cpp:25
void StopPhase() override
Stop measurement of the current phase.
Definition: phase_scope.cpp:35
virtual ~PhaseScope()
Benchmark phase will be stopped on destructing.
Definition: phase_scope.cpp:16
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.
Definition: phase_scope.cpp:44
C++ Benchmark project definitions.
Definition: barrier.h:15
Benchmark phase scope definition.