cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
runner.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <memory>
23#include <utility>
24#include <vector>
25
32
33namespace stat_bench {
34namespace runner {
35
39class Runner {
40public:
47 explicit Runner(const Config& config,
50
56 explicit Runner(bench_impl::BenchmarkCaseRegistry& registry =
58
59 Runner(const Runner&) = delete;
60 Runner(Runner&&) = delete;
61 auto operator=(const Runner&) -> Runner& = delete;
62 auto operator=(Runner&&) -> Runner& = delete;
63
68
74 void add(std::shared_ptr<measurer::IMeasurer> measurer) {
75 measurers_.push_back(std::move(measurer));
76 }
77
83 void add(std::shared_ptr<reporter::IReporter> reporter) {
84 reporters_.push_back(std::move(reporter));
85 }
86
90 void run() const;
91
92private:
99 void run_case(const std::shared_ptr<measurer::IMeasurer>& measurer,
100 const std::shared_ptr<bench_impl::IBenchmarkCase>& bench_case) const;
101
109 void run_case_with_condition(
110 const std::shared_ptr<measurer::IMeasurer>& measurer,
111 const std::shared_ptr<bench_impl::IBenchmarkCase>& bench_case,
112 const BenchmarkCondition& cond) const;
113
115 std::vector<std::shared_ptr<measurer::IMeasurer>> measurers_{};
116
118 std::vector<std::shared_ptr<reporter::IReporter>> reporters_{};
119
121 bench_impl::BenchmarkCaseRegistry& registry_;
122};
123
124} // namespace runner
125} // namespace stat_bench
Definition of BenchmarkCaseRegistry class.
Definition of BenchmarkCondition class.
Class of conditions of benchmarks.
Class of registry of cases of benchmarks.
static auto instance() -> BenchmarkCaseRegistry &
Get an instance of the registry.
void add(std::shared_ptr< measurer::IMeasurer > measurer)
Add a measurer.
Definition runner.h:74
void run() const
Run benchmarks.
Definition runner.cpp:102
void add(std::shared_ptr< reporter::IReporter > reporter)
Add a reporter.
Definition runner.h:83
Runner(const Config &config, bench_impl::BenchmarkCaseRegistry &registry=bench_impl::BenchmarkCaseRegistry::instance())
Constructor.
Definition runner.cpp:48
Definition of Runner class.
Definition of IBenchmarkCase class.
Definition of IMeasurer class.
Definition of IReporter class.
Namespace of classes to measure time in benchmarks.
Namespace of reporters of results of benchmarks.
Namespace of classes to run benchmarks.
Namespace of stat_bench source codes.
Class of configurations.
Definition config.h:54