cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
measurement.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 <cstddef>
23#include <memory>
24#include <utility>
25#include <vector>
26
35
36namespace stat_bench {
37namespace measurer {
38
43public:
57 MeasurerName measurer_name, std::size_t iterations, std::size_t samples,
58 std::vector<std::vector<clock::Duration>> durations,
59 std::vector<std::shared_ptr<stat::CustomStatOutput>>
61 std::vector<std::pair<CustomOutputName, double>> custom_outputs)
62 : case_info_(std::move(case_info)),
63 cond_(std::move(cond)),
64 measurer_name_(std::move(measurer_name)),
65 iterations_(iterations),
66 samples_(samples),
67 durations_(std::move(durations)),
68 durations_stat_(stat::calc_stat(durations_, iterations)),
69 custom_stat_outputs_(std::move(custom_stat_outputs)),
70 custom_outputs_(std::move(custom_outputs)) {
71 custom_stat_.reserve(custom_stat_outputs_.size());
72 for (const auto& out : custom_stat_outputs_) {
73 out->preprocess(durations_);
74 custom_stat_.push_back(out->stat());
75 }
76 }
77
83 [[nodiscard]] auto case_info() const noexcept -> const BenchmarkFullName& {
84 return case_info_;
85 }
86
92 [[nodiscard]] auto cond() const noexcept -> const BenchmarkCondition& {
93 return cond_;
94 }
95
101 [[nodiscard]] auto measurer_name() const noexcept -> const MeasurerName& {
102 return measurer_name_;
103 }
104
110 [[nodiscard]] auto iterations() const noexcept -> const std::size_t& {
111 return iterations_;
112 }
113
119 [[nodiscard]] auto samples() const noexcept -> const std::size_t& {
120 return samples_;
121 }
122
130 [[nodiscard]] auto durations() const noexcept
131 -> const std::vector<std::vector<clock::Duration>>& {
132 return durations_;
133 }
134
140 [[nodiscard]] auto durations_stat() const noexcept
141 -> const stat::Statistics& {
142 return durations_stat_;
143 }
144
150 [[nodiscard]] auto custom_stat_outputs() const noexcept
151 -> const std::vector<std::shared_ptr<stat::CustomStatOutput>>& {
152 return custom_stat_outputs_;
153 }
154
160 [[nodiscard]] auto custom_stat() const noexcept
161 -> const std::vector<stat::Statistics>& {
162 return custom_stat_;
163 }
164
170 [[nodiscard]] auto custom_outputs() const noexcept
171 -> const std::vector<std::pair<CustomOutputName, double>>& {
172 return custom_outputs_;
173 }
174
175private:
177 BenchmarkFullName case_info_;
178
180 BenchmarkCondition cond_;
181
183 MeasurerName measurer_name_;
184
186 std::size_t iterations_;
187
189 std::size_t samples_;
190
192 std::vector<std::vector<clock::Duration>> durations_;
193
195 stat::Statistics durations_stat_;
196
198 std::vector<std::shared_ptr<stat::CustomStatOutput>> custom_stat_outputs_;
199
201 std::vector<stat::Statistics> custom_stat_;
202
204 std::vector<std::pair<CustomOutputName, double>> custom_outputs_;
205};
206
207} // namespace measurer
208} // namespace stat_bench
Definition of BenchmarkCondition class.
Definition of BenchmarkFullName class.
Declaration of calc_stat function.
Class of conditions of benchmarks.
Class of information of cases in benchmarks.
Class of names of custom outputs.
auto custom_stat() const noexcept -> const std::vector< stat::Statistics > &
Get the statistics of custom outputs.
auto durations() const noexcept -> const std::vector< std::vector< clock::Duration > > &
Get the measured durations.
auto iterations() const noexcept -> const std::size_t &
Get the number of iterations.
auto samples() const noexcept -> const std::size_t &
Get the number of samples.
Measurement(BenchmarkFullName case_info, BenchmarkCondition cond, MeasurerName measurer_name, std::size_t iterations, std::size_t samples, std::vector< std::vector< clock::Duration > > durations, std::vector< std::shared_ptr< stat::CustomStatOutput > > custom_stat_outputs, std::vector< std::pair< CustomOutputName, double > > custom_outputs)
Constructor.
Definition measurement.h:56
auto cond() const noexcept -> const BenchmarkCondition &
Get the condition.
Definition measurement.h:92
auto measurer_name() const noexcept -> const MeasurerName &
Get the name of the measurer.
auto custom_stat_outputs() const noexcept -> const std::vector< std::shared_ptr< stat::CustomStatOutput > > &
Get the custom outputs with statistics.
auto case_info() const noexcept -> const BenchmarkFullName &
Get the information of the case.
Definition measurement.h:83
auto durations_stat() const noexcept -> const stat::Statistics &
Get the statistics of durations.
auto custom_outputs() const noexcept -> const std::vector< std::pair< CustomOutputName, double > > &
Get the custom outputs without statistics.
Class of names of measurers.
Class to calculate statistics.
Definition statistics.h:31
Definition of CustomOutputName class.
Definition of CustomStatOutput class.
Definition of Duration class.
Definition of MeasurerName class.
Namespace of clocks for benchmarks.
Definition duration.h:23
Namespace of classes to measure time in benchmarks.
Namespace of statistics.
Definition calc_stat.h:29
Namespace of stat_bench source codes.
STL namespace.
Definition of Statistics class.