Project
Loading...
Searching...
No Matches
benchmark_DataDescriptorMatcher.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#include <benchmark/benchmark.h>
12#include "Headers/DataHeader.h"
14
15using namespace o2::header;
16using namespace o2::framework::data_matcher;
17
18static void BM_MatchedSingleQuery(benchmark::State& state)
19{
20 DataHeader header;
21 header.dataOrigin = "TRD";
22 header.dataDescription = "TRACKLET";
23 header.subSpecification = 0;
24
26 DataDescriptorMatcher::Op::Just,
27 OriginValueMatcher{"TRD"}};
28
29 VariableContext context;
30
31 for (auto _ : state) {
32 matcher.match(header, context);
33 }
34}
35
36BENCHMARK(BM_MatchedSingleQuery);
37
38static void BM_MatchedFullQuery(benchmark::State& state)
39{
40 DataHeader header;
41 header.dataOrigin = "TRD";
42 header.dataDescription = "TRACKLET";
43 header.subSpecification = 0;
44
46 DataDescriptorMatcher::Op::And,
47 OriginValueMatcher{"TRD"},
48 std::make_unique<DataDescriptorMatcher>(
49 DataDescriptorMatcher::Op::And,
50 DescriptionValueMatcher{"TRACKLET"},
51 std::make_unique<DataDescriptorMatcher>(
52 DataDescriptorMatcher::Op::And,
54 ConstantValueMatcher{true}))};
55
56 VariableContext context;
57
58 for (auto _ : state) {
59 matcher.match(header, context);
60 }
61}
62// Register the function as a benchmark
63BENCHMARK(BM_MatchedFullQuery);
64
65static void BM_UnmatchedSingleQuery(benchmark::State& state)
66{
67 DataHeader header;
68 header.dataOrigin = "TRD";
69 header.dataDescription = "TRACKLET";
70 header.subSpecification = 0;
71
73 DataDescriptorMatcher::Op::And,
74 OriginValueMatcher{"TDR"},
75 std::make_unique<DataDescriptorMatcher>(
76 DataDescriptorMatcher::Op::And,
77 DescriptionValueMatcher{"TRACKLET"},
78 std::make_unique<DataDescriptorMatcher>(
79 DataDescriptorMatcher::Op::And,
81 ConstantValueMatcher{true}))};
82
83 VariableContext context;
84
85 for (auto _ : state) {
86 matcher.match(header, context);
87 }
88}
89
90// Register the function as a benchmark
91BENCHMARK(BM_UnmatchedSingleQuery);
92
93static void BM_UnmatchedFullQuery(benchmark::State& state)
94{
95 DataHeader header;
96 header.dataOrigin = "TRD";
97 header.dataDescription = "TRACKLET";
98 header.subSpecification = 0;
99
100 DataDescriptorMatcher matcher{
101 DataDescriptorMatcher::Op::And,
102 OriginValueMatcher{"TRD"},
103 std::make_unique<DataDescriptorMatcher>(
104 DataDescriptorMatcher::Op::And,
105 DescriptionValueMatcher{"TRACKLET"},
106 std::make_unique<DataDescriptorMatcher>(
107 DataDescriptorMatcher::Op::And,
109 ConstantValueMatcher{true}))};
110
111 VariableContext context;
112
113 for (auto _ : state) {
114 matcher.match(header, context);
115 }
116}
117// Register the function as a benchmark
118BENCHMARK(BM_UnmatchedFullQuery);
119
120static void BM_OneVariableFullMatch(benchmark::State& state)
121{
122 DataHeader header;
123 header.dataOrigin = "TRD";
124 header.dataDescription = "TRACKLET";
125 header.subSpecification = 0;
126
127 DataDescriptorMatcher matcher{
128 DataDescriptorMatcher::Op::And,
130 std::make_unique<DataDescriptorMatcher>(
131 DataDescriptorMatcher::Op::And,
132 DescriptionValueMatcher{"TRACKLET"},
133 std::make_unique<DataDescriptorMatcher>(
134 DataDescriptorMatcher::Op::And,
136 ConstantValueMatcher{true}))};
137
138 VariableContext context;
139
140 for (auto _ : state) {
141 matcher.match(header, context);
142 context.discard();
143 }
144}
145// Register the function as a benchmark
146BENCHMARK(BM_OneVariableFullMatch);
147
148static void BM_OneVariableMatchUnmatch(benchmark::State& state)
149{
150 DataHeader header0;
151 header0.dataOrigin = "TRD";
152 header0.dataDescription = "TRACKLET";
153 header0.subSpecification = 0;
154
155 DataHeader header1;
156 header1.dataOrigin = "TPC";
157 header1.dataDescription = "CLUSTERS";
158 header1.subSpecification = 0;
159
160 DataDescriptorMatcher matcher{
161 DataDescriptorMatcher::Op::And,
163 std::make_unique<DataDescriptorMatcher>(
164 DataDescriptorMatcher::Op::And,
165 DescriptionValueMatcher{"TRACKLET"},
166 std::make_unique<DataDescriptorMatcher>(
167 DataDescriptorMatcher::Op::And,
169 ConstantValueMatcher{true}))};
170
171 VariableContext context;
172
173 for (auto _ : state) {
174 matcher.match(header0, context);
175 matcher.match(header1, context);
176 context.discard();
177 }
178}
179// Register the function as a benchmark
180BENCHMARK(BM_OneVariableMatchUnmatch);
181
benchmark::State & state
BENCHMARK(BM_MatchedSingleQuery)
BENCHMARK_MAIN()
Something which can be matched against a header::DataDescription.
Something which can be matched against a header::DataOrigin.
Something which can be matched against a header::SubSpecificationType.
O2 data header classes and API, v0.1.
Definition DetID.h:49
A typesafe reference to an element of the context.
the main header struct
Definition DataHeader.h:618
DataDescription dataDescription
Definition DataHeader.h:636
SubSpecificationType subSpecification
Definition DataHeader.h:656