CppBenchmark  1.0.4.0
C++ Benchmark Library
benchmark_pc.h
Go to the documentation of this file.
1 
9 #ifndef CPPBENCHMARK_BENCHMARK_PC_H
10 #define CPPBENCHMARK_BENCHMARK_PC_H
11 
13 #include "benchmark/context_pc.h"
14 #include "benchmark/fixture_pc.h"
15 #include "benchmark/settings_pc.h"
16 
17 #include <thread>
18 
19 namespace CppBenchmark {
20 
22 
25 class BenchmarkPC : public BenchmarkBase, public virtual FixturePC
26 {
27 public:
30 
32 
36  template<typename... Types>
37  explicit BenchmarkPC(const std::string& name, Types... settings) : BenchmarkPC(name, TSettings(settings...)) {}
39 
43  explicit BenchmarkPC(const std::string& name, const TSettings& settings) : BenchmarkBase(name, settings) {}
44  BenchmarkPC(const BenchmarkPC&) = delete;
45  BenchmarkPC(BenchmarkPC&&) = delete;
46  virtual ~BenchmarkPC() = default;
47 
48  BenchmarkPC& operator=(const BenchmarkPC&) = delete;
50 
51 protected:
53 
59  virtual void RunProducer(ContextPC& context) = 0;
61 
67  virtual void RunConsumer(ContextPC& context) = 0;
68 
69 private:
70  std::vector<std::thread> _threads;
71 
72  int CountLaunches() const override;
73  void Launch(int& current, int total, LauncherHandler& handler) override;
74 };
75 
80 } // namespace CppBenchmark
81 
82 #endif // CPPBENCHMARK_BENCHMARK_PC_H
Benchmark base definition.
Benchmark base class.
const Settings & settings() const
Get benchmark settings.
const std::string & name() const
Get benchmark name.
Producers/Consumers benchmark base class.
Definition: benchmark_pc.h:26
BenchmarkPC(const std::string &name, const TSettings &settings)
Alternative class constructor.
Definition: benchmark_pc.h:43
virtual ~BenchmarkPC()=default
BenchmarkPC(const BenchmarkPC &)=delete
BenchmarkPC(const std::string &name, Types... settings)
Default class constructor.
Definition: benchmark_pc.h:37
BenchmarkPC & operator=(const BenchmarkPC &)=delete
virtual void RunConsumer(ContextPC &context)=0
Consumer run method.
BenchmarkPC(BenchmarkPC &&)=delete
virtual void RunProducer(ContextPC &context)=0
Producer run method.
BenchmarkPC & operator=(BenchmarkPC &&)=delete
SettingsPC TSettings
BenchmarkPC settings type.
Definition: benchmark_pc.h:29
Benchmark producer/consumer running context.
Definition: context_pc.h:27
Producers/Consumers benchmark fixture.
Definition: fixture_pc.h:21
Producers/Consumers benchmark settings.
Definition: settings_pc.h:21
Benchmark producer/consumer running context definition.
Producers/Consumers benchmark fixture definition.
C++ Benchmark project definitions.
Definition: barrier.h:15
Producers/Consumers benchmark settings definition.