CppBenchmark  1.0.4.0
C++ Benchmark Library
benchmark_base.h
Go to the documentation of this file.
1 
9 #ifndef CPPBENCHMARK_BENCHMARK_BASE_H
10 #define CPPBENCHMARK_BENCHMARK_BASE_H
11 
12 #include "benchmark/context.h"
13 #include "benchmark/phase_core.h"
14 #include "benchmark/settings.h"
15 
16 namespace CppBenchmark {
17 
18 class LauncherHandler;
19 
21 
25 {
26  friend class Executor;
27  friend class Launcher;
28 
29 public:
31 
35  template<typename... Types>
36  explicit BenchmarkBase(const std::string& name, Types... settings)
38  {}
40 
44  explicit BenchmarkBase(const std::string& name, const Settings& settings)
46  {}
47  BenchmarkBase(const BenchmarkBase&) = delete;
49  virtual ~BenchmarkBase() = default;
50 
53 
55  const std::string& name() const { return _name; }
57  const Settings& settings() const { return _settings; }
58 
59 protected:
61  bool _launched;
63  std::string _name;
67  std::vector<std::shared_ptr<PhaseCore>> _phases;
68 
70 
73  virtual int CountLaunches() const { return 1; }
74 
76 
81  virtual void Launch(int& current, int total, LauncherHandler& handler) {}
82 
84 
87  void InitBenchmarkContext(Context& context);
88 
90 
93  static void UpdateBenchmarkMetrics(std::vector<std::shared_ptr<PhaseCore>>& phases);
95 
98  static void UpdateBenchmarkMetrics(PhaseCore& phase);
99 
101 
104  static void UpdateBenchmarkThreads(std::vector<std::shared_ptr<PhaseCore>>& phases);
105 
107 
110  static void UpdateBenchmarkNames(std::vector<std::shared_ptr<PhaseCore>>& phases);
112 
116  static void UpdateBenchmarkNames(PhaseCore& phase, const std::string& name);
117 
119 
122  static void UpdateBenchmarkOperations(std::vector<std::shared_ptr<PhaseCore>>& phases);
124 
127  static void UpdateBenchmarkOperations(PhaseCore& phase);
128 };
129 
130 } // namespace CppBenchmark
131 
132 #endif // CPPBENCHMARK_BENCHMARK_BASE_H
Benchmark base class.
bool _launched
Benchmark launched flag.
BenchmarkBase(const std::string &name, Types... settings)
Default class constructor.
virtual int CountLaunches() const
Get the count of benchmark launches.
BenchmarkBase & operator=(const BenchmarkBase &)=delete
Settings _settings
Benchmark settings.
static void UpdateBenchmarkNames(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark names for the given benchmark phases collection.
const Settings & settings() const
Get benchmark settings.
void InitBenchmarkContext(Context &context)
Initialize benchmark context.
static void UpdateBenchmarkThreads(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark threads metrics for the given benchmark phases collection.
BenchmarkBase(BenchmarkBase &&)=delete
BenchmarkBase(const BenchmarkBase &)=delete
const std::string & name() const
Get benchmark name.
BenchmarkBase & operator=(BenchmarkBase &&)=delete
std::string _name
Benchmark name.
static void UpdateBenchmarkOperations(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark operations for the given benchmark phases collection.
virtual ~BenchmarkBase()=default
virtual void Launch(int &current, int total, LauncherHandler &handler)
Get the count of benchmark launches.
BenchmarkBase(const std::string &name, const Settings &settings)
Alternative class constructor.
static void UpdateBenchmarkMetrics(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark metrics for the given benchmark phases collection.
std::vector< std::shared_ptr< PhaseCore > > _phases
Benchmark phases.
Benchmark running context.
Definition: context.h:27
Dynamic benchmarks executor class.
Definition: executor.h:22
Launcher base class.
Definition: launcher.h:25
Benchmark phase core.
Definition: phase_core.h:27
Benchmark settings.
Definition: settings.h:32
Benchmark running context definition.
C++ Benchmark project definitions.
Definition: barrier.h:15
Benchmark phase core definition.
Benchmark settings definition.