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:
58 std::size_t samples,
59 std::vector<std::vector<clock::Duration>> durations,
60 std::vector<std::shared_ptr<stat::CustomStatOutput>>
62 std::vector<std::pair<CustomOutputName, double>> custom_outputs)
63 : case_info_(std::move(case_info)),
64 cond_(std::move(cond)),
65 measurement_type_(std::move(measurement_type)),
66 iterations_(iterations),
67 samples_(samples),
68 durations_(std::move(durations)),
69 durations_stat_(stat::calc_stat(durations_, iterations)),
70 custom_stat_outputs_(std::move(custom_stat_outputs)),
71 custom_outputs_(std::move(custom_outputs)) {
72 custom_stat_.reserve(custom_stat_outputs_.size());
73 for (const auto& out : custom_stat_outputs_) {
74 out->preprocess(durations_);
75 custom_stat_.push_back(out->stat());
76 }
77 }
78
84 [[nodiscard]] auto case_info() const noexcept -> const BenchmarkFullName& {
85 return case_info_;
86 }
87
93 [[nodiscard]] auto cond() const noexcept -> const BenchmarkCondition& {
94 return cond_;
95 }
96
102 [[nodiscard]] auto measurement_type() const noexcept
103 -> const MeasurementType& {
104 return measurement_type_;
105 }
106
112 [[nodiscard]] auto iterations() const noexcept -> const std::size_t& {
113 return iterations_;
114 }
115
121 [[nodiscard]] auto samples() const noexcept -> const std::size_t& {
122 return samples_;
123 }
124
132 [[nodiscard]] auto durations() const noexcept
133 -> const std::vector<std::vector<clock::Duration>>& {
134 return durations_;
135 }
136
142 [[nodiscard]] auto durations_stat() const noexcept
143 -> const stat::Statistics& {
144 return durations_stat_;
145 }
146
152 [[nodiscard]] auto custom_stat_outputs() const noexcept
153 -> const std::vector<std::shared_ptr<stat::CustomStatOutput>>& {
154 return custom_stat_outputs_;
155 }
156
162 [[nodiscard]] auto custom_stat() const noexcept
163 -> const std::vector<stat::Statistics>& {
164 return custom_stat_;
165 }
166
172 [[nodiscard]] auto custom_outputs() const noexcept
173 -> const std::vector<std::pair<CustomOutputName, double>>& {
174 return custom_outputs_;
175 }
176
177private:
179 BenchmarkFullName case_info_;
180
182 BenchmarkCondition cond_;
183
185 MeasurementType measurement_type_;
186
188 std::size_t iterations_;
189
191 std::size_t samples_;
192
194 std::vector<std::vector<clock::Duration>> durations_;
195
197 stat::Statistics durations_stat_;
198
200 std::vector<std::shared_ptr<stat::CustomStatOutput>> custom_stat_outputs_;
201
203 std::vector<stat::Statistics> custom_stat_;
204
206 std::vector<std::pair<CustomOutputName, double>> custom_outputs_;
207};
208
209} // namespace measurer
210} // 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.
Class of names of measurement types.
auto measurement_type() const noexcept -> const MeasurementType &
Get the name of the measurer.
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.
auto cond() const noexcept -> const BenchmarkCondition &
Get the condition.
Definition measurement.h:93
Measurement(BenchmarkFullName case_info, BenchmarkCondition cond, MeasurementType measurement_type, 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 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:84
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 to calculate statistics.
Definition statistics.h:31
Definition of CustomOutputName class.
Definition of CustomStatOutput class.
Definition of Duration class.
Definition of MeasurementType 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.