cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
parameter_generator.cpp
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 */
21
25
26namespace stat_bench {
27namespace param {
28
30 std::pair<ParameterName, std::shared_ptr<IParameterValueVector>>>& params) {
31 params_.reserve(params.size());
32 for (const auto& param : params) {
33 if (param.second->size() == 0) {
34 continue;
35 }
36 params_.push_back(ParamData{param.first, param.second,
37 param.second->begin(), param.second->begin(), param.second->end()});
38 }
39}
40
42 for (auto iter = params_.rbegin(); iter != params_.rend(); ++iter) {
43 ++(iter->next);
44 if (iter->next != iter->end) {
45 return true;
46 }
47 iter->next = iter->begin;
48 }
49 return false;
50}
51
54 data.reserve(params_.size());
55 for (const auto& param : params_) {
56 data.try_emplace(param.name, *param.next);
57 }
58 return ParameterDict(data);
59}
60
61} // namespace param
62} // namespace stat_bench
Class of dictionaries of parameters.
ParameterGenerator(const std::vector< std::pair< ParameterName, std::shared_ptr< IParameterValueVector > > > &params)
Constructor.
auto generate() const -> ParameterDict
Generate the parameters.
Class of names of parameters.
Class of mapping which preserves order of insertion.
Definition ordered_map.h:39
auto try_emplace(const Key &key, Args &&... args) -> std::pair< iterator, bool >
Insert a pair if the key does not exist.
void reserve(std::size_t size)
Reserve memory space.
Namespace of parameters of benchmarks.
Namespace of stat_bench source codes.
Definition of OrderedMap class.
Definition of ParameterGenerator class.
Definition of ParameterName class.
Definition of ParameterValue class.