CppBenchmark  1.0.4.0
C++ Benchmark Library
launcher.h
Go to the documentation of this file.
1 
9 #ifndef CPPBENCHMARK_LAUNCHER_H
10 #define CPPBENCHMARK_LAUNCHER_H
11 
12 #include "benchmark/benchmark.h"
13 #include "benchmark/benchmark_pc.h"
16 #include "benchmark/reporter.h"
17 
18 namespace CppBenchmark {
19 
21 
24 class Launcher : public LauncherHandler
25 {
26 public:
27  Launcher() = default;
28  Launcher(const Launcher&) = delete;
29  Launcher(Launcher&&) = delete;
30  virtual ~Launcher() = default;
31 
32  Launcher& operator=(const Launcher&) = delete;
33  Launcher& operator=(Launcher&&) = delete;
34 
36 
39  void AddBenchmark(const std::shared_ptr<BenchmarkBase>& benchmark) { _benchmarks.emplace_back(benchmark); }
41  void ClearAllBenchmarks() { _benchmarks.clear(); }
42 
44 
47  void AddBenchmarkBuilder(const std::function<std::shared_ptr<BenchmarkBase>()>& builder) { if (builder) _builders.emplace_back(builder); }
50 
52 
58  virtual void Launch(const std::string& pattern = "");
59 
61 
64  void Report(Reporter& reporter) const;
66 
69  void ReportHistograms(int32_t resolution) const;
70 
71 protected:
73  std::vector<std::shared_ptr<BenchmarkBase>> _benchmarks;
75  std::vector<std::function<std::shared_ptr<BenchmarkBase>()>> _builders;
76 
77 private:
78  void ReportPhase(Reporter& reporter, const PhaseCore& phase, const std::string& name) const;
79  void ReportPhaseHistograms(int32_t resolution, const PhaseCore& phase, const std::string& name) const;
80  void ReportPhaseHistogram(int32_t resolution, const PhaseCore& phase, const std::string& name) const;
81 };
82 
83 } // namespace CppBenchmark
84 
85 #endif // CPPBENCHMARK_LAUNCHER_H
Benchmark definition.
Producers/Consumers benchmark base definition.
Threads benchmark base definition.
Launcher base class.
Definition: launcher.h:25
void ClearAllBenchmarks()
Clear benchmarks collection.
Definition: launcher.h:41
virtual void Launch(const std::string &pattern="")
Launch registered benchmarks.
Definition: launcher.cpp:16
Launcher(Launcher &&)=delete
Launcher & operator=(const Launcher &)=delete
std::vector< std::function< std::shared_ptr< BenchmarkBase >)> > _builders
Benchmark builders collection.
Definition: launcher.h:75
void Report(Reporter &reporter) const
Report benchmarks results using the given reporter.
Definition: launcher.cpp:43
Launcher & operator=(Launcher &&)=delete
void AddBenchmarkBuilder(const std::function< std::shared_ptr< BenchmarkBase >()> &builder)
Add the given benchmark builder function to the benchmark builders collection.
Definition: launcher.h:47
virtual ~Launcher()=default
void ReportHistograms(int32_t resolution) const
Report benchmarks High Dynamic Range (HDR) Histograms.
Definition: launcher.cpp:85
std::vector< std::shared_ptr< BenchmarkBase > > _benchmarks
Registered benchmarks collection.
Definition: launcher.h:73
Launcher(const Launcher &)=delete
void ClearAllBenchmarksBuilders()
Clear benchmark builders collection.
Definition: launcher.h:49
void AddBenchmark(const std::shared_ptr< BenchmarkBase > &benchmark)
Add the given benchmark to the benchmarks collection.
Definition: launcher.h:39
Benchmark phase core.
Definition: phase_core.h:27
Reporter base class.
Definition: reporter.h:21
Launcher handler definition.
C++ Benchmark project definitions.
Definition: barrier.h:15
Reporter base definition.