cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
composed_filter.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 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
22#include <algorithm>
23#include <memory>
24
27
28namespace stat_bench {
29namespace filters {
30
31void ComposedFilter::include_with_glob(const std::string& pattern) {
32 included_filter_.push_back(std::make_shared<GlobFilter>(pattern));
33}
34
35void ComposedFilter::exclude_with_glob(const std::string& pattern) {
36 excluded_filter_.push_back(std::make_shared<GlobFilter>(pattern));
37}
38
39void ComposedFilter::include_with_regex(const std::string& regex) {
40 included_filter_.push_back(std::make_shared<RegexFilter>(regex));
41}
42
43void ComposedFilter::exclude_with_regex(const std::string& regex) {
44 excluded_filter_.push_back(std::make_shared<RegexFilter>(regex));
45}
46
47auto ComposedFilter::check(const BenchmarkFullName& name) const -> bool {
48 return (included_filter_.empty() ||
49 std::any_of(included_filter_.begin(), included_filter_.end(),
50 [&name](const std::shared_ptr<INameFilter>& filter) {
51 return filter->check(name);
52 })) &&
53 std::none_of(excluded_filter_.begin(), excluded_filter_.end(),
54 [&name](const std::shared_ptr<INameFilter>& filter) {
55 return filter->check(name);
56 });
57}
58
59} // namespace filters
60} // namespace stat_bench
Class of information of cases in benchmarks.
void include_with_regex(const std::string &regex)
Add a filter of benchmark names to include using regular expressions.
void include_with_glob(const std::string &pattern)
Add a filter of benchmark names to include using glob patterns.
void exclude_with_regex(const std::string &regex)
Add a filter of benchmark names to exclude using regular expressions.
void exclude_with_glob(const std::string &pattern)
Add a filter of benchmark names to exclude using glob patterns.
auto check(const BenchmarkFullName &name) const -> bool
Check whether a name matches to this filter.
Definition of ComposedFilter class.
Definition of GlobFilter class.
Namespace of filters of benchmarks.
Namespace of stat_bench source codes.
Definition of RegexFilter class.