CppBenchmark  1.0.4.0
C++ Benchmark Library
phase.h
Go to the documentation of this file.
1 
9 #ifndef CPPBENCHMARK_PHASE_H
10 #define CPPBENCHMARK_PHASE_H
11 
13 
14 #include <memory>
15 
16 namespace CppBenchmark {
17 
18 class PhaseScope;
19 
21 
25 class Phase
26 {
27 public:
28  Phase() noexcept = default;
29  Phase(const Phase&) = default;
30  Phase(Phase&&) noexcept = default;
31  virtual ~Phase() = default;
32 
33  Phase& operator=(const Phase&) = default;
34  Phase& operator=(Phase&&) noexcept = default;
35 
37  virtual const std::string& name() const noexcept = 0;
39  virtual const PhaseMetrics& metrics() const noexcept = 0;
40 
42 
50  virtual std::shared_ptr<Phase> StartPhase(const std::string& phase) = 0;
51 
53 
60  virtual std::shared_ptr<Phase> StartPhaseThreadSafe(const std::string& phase) = 0;
61 
63  virtual void StopPhase() = 0;
64 
66 
72  virtual std::shared_ptr<PhaseScope> ScopePhase(const std::string& phase) = 0;
73 
75 
81  virtual std::shared_ptr<PhaseScope> ScopePhaseThreadSafe(const std::string& phase) = 0;
82 };
83 
84 } // namespace CppBenchmark
85 
86 #endif // CPPBENCHMARK_PHASE_H
Benchmark phase base class.
Definition: phase.h:26
virtual std::shared_ptr< PhaseScope > ScopePhaseThreadSafe(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.
virtual std::shared_ptr< Phase > StartPhaseThreadSafe(const std::string &phase)=0
Start a new sub-phase with a given name in a multi-thread environment.
virtual std::shared_ptr< Phase > StartPhase(const std::string &phase)=0
Start a new sub-phase with a given name in a single-thread environment.
virtual std::shared_ptr< PhaseScope > ScopePhase(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.
virtual const PhaseMetrics & metrics() const noexcept=0
Get phase metrics.
virtual const std::string & name() const noexcept=0
Get phase name.
virtual void StopPhase()=0
Stop measurement of the current phase.
Phase() noexcept=default
Benchmark phase metrics.
Definition: phase_metrics.h:37
Benchmark phase scope.
Definition: phase_scope.h:22
C++ Benchmark project definitions.
Definition: barrier.h:15
Benchmark phase metrics definition.