[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / third-party / benchmark / test / repetitions_test.cc
blob569777d5f933ef0b99587f829dede8bcb6456aa6
2 #include "benchmark/benchmark.h"
3 #include "output_test.h"
5 // ========================================================================= //
6 // ------------------------ Testing Basic Output --------------------------- //
7 // ========================================================================= //
9 static void BM_ExplicitRepetitions(benchmark::State& state) {
10 for (auto _ : state) {
13 BENCHMARK(BM_ExplicitRepetitions)->Repetitions(2);
15 ADD_CASES(TC_ConsoleOut,
16 {{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
17 ADD_CASES(TC_ConsoleOut,
18 {{"^BM_ExplicitRepetitions/repeats:2 %console_report$"}});
19 ADD_CASES(TC_ConsoleOut,
20 {{"^BM_ExplicitRepetitions/repeats:2_mean %console_report$"}});
21 ADD_CASES(TC_ConsoleOut,
22 {{"^BM_ExplicitRepetitions/repeats:2_median %console_report$"}});
23 ADD_CASES(TC_ConsoleOut,
24 {{"^BM_ExplicitRepetitions/repeats:2_stddev %console_report$"}});
25 ADD_CASES(TC_JSONOut,
26 {{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
27 {"\"family_index\": 0,$", MR_Next},
28 {"\"per_family_instance_index\": 0,$", MR_Next},
29 {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
30 {"\"run_type\": \"iteration\",$", MR_Next},
31 {"\"repetitions\": 2,$", MR_Next},
32 {"\"repetition_index\": 0,$", MR_Next},
33 {"\"threads\": 1,$", MR_Next},
34 {"\"iterations\": %int,$", MR_Next},
35 {"\"real_time\": %float,$", MR_Next},
36 {"\"cpu_time\": %float,$", MR_Next},
37 {"\"time_unit\": \"ns\"$", MR_Next},
38 {"}", MR_Next}});
39 ADD_CASES(TC_JSONOut,
40 {{"\"name\": \"BM_ExplicitRepetitions/repeats:2\",$"},
41 {"\"family_index\": 0,$", MR_Next},
42 {"\"per_family_instance_index\": 0,$", MR_Next},
43 {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
44 {"\"run_type\": \"iteration\",$", MR_Next},
45 {"\"repetitions\": 2,$", MR_Next},
46 {"\"repetition_index\": 1,$", MR_Next},
47 {"\"threads\": 1,$", MR_Next},
48 {"\"iterations\": %int,$", MR_Next},
49 {"\"real_time\": %float,$", MR_Next},
50 {"\"cpu_time\": %float,$", MR_Next},
51 {"\"time_unit\": \"ns\"$", MR_Next},
52 {"}", MR_Next}});
53 ADD_CASES(TC_JSONOut,
54 {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_mean\",$"},
55 {"\"family_index\": 0,$", MR_Next},
56 {"\"per_family_instance_index\": 0,$", MR_Next},
57 {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
58 {"\"run_type\": \"aggregate\",$", MR_Next},
59 {"\"repetitions\": 2,$", MR_Next},
60 {"\"threads\": 1,$", MR_Next},
61 {"\"aggregate_name\": \"mean\",$", MR_Next},
62 {"\"aggregate_unit\": \"time\",$", MR_Next},
63 {"\"iterations\": %int,$", MR_Next},
64 {"\"real_time\": %float,$", MR_Next},
65 {"\"cpu_time\": %float,$", MR_Next},
66 {"\"time_unit\": \"ns\"$", MR_Next},
67 {"}", MR_Next}});
68 ADD_CASES(TC_JSONOut,
69 {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_median\",$"},
70 {"\"family_index\": 0,$", MR_Next},
71 {"\"per_family_instance_index\": 0,$", MR_Next},
72 {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
73 {"\"run_type\": \"aggregate\",$", MR_Next},
74 {"\"repetitions\": 2,$", MR_Next},
75 {"\"threads\": 1,$", MR_Next},
76 {"\"aggregate_name\": \"median\",$", MR_Next},
77 {"\"aggregate_unit\": \"time\",$", MR_Next},
78 {"\"iterations\": %int,$", MR_Next},
79 {"\"real_time\": %float,$", MR_Next},
80 {"\"cpu_time\": %float,$", MR_Next},
81 {"\"time_unit\": \"ns\"$", MR_Next},
82 {"}", MR_Next}});
83 ADD_CASES(TC_JSONOut,
84 {{"\"name\": \"BM_ExplicitRepetitions/repeats:2_stddev\",$"},
85 {"\"family_index\": 0,$", MR_Next},
86 {"\"per_family_instance_index\": 0,$", MR_Next},
87 {"\"run_name\": \"BM_ExplicitRepetitions/repeats:2\",$", MR_Next},
88 {"\"run_type\": \"aggregate\",$", MR_Next},
89 {"\"repetitions\": 2,$", MR_Next},
90 {"\"threads\": 1,$", MR_Next},
91 {"\"aggregate_name\": \"stddev\",$", MR_Next},
92 {"\"aggregate_unit\": \"time\",$", MR_Next},
93 {"\"iterations\": %int,$", MR_Next},
94 {"\"real_time\": %float,$", MR_Next},
95 {"\"cpu_time\": %float,$", MR_Next},
96 {"\"time_unit\": \"ns\"$", MR_Next},
97 {"}", MR_Next}});
98 ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
99 ADD_CASES(TC_CSVOut, {{"^\"BM_ExplicitRepetitions/repeats:2\",%csv_report$"}});
100 ADD_CASES(TC_CSVOut,
101 {{"^\"BM_ExplicitRepetitions/repeats:2_mean\",%csv_report$"}});
102 ADD_CASES(TC_CSVOut,
103 {{"^\"BM_ExplicitRepetitions/repeats:2_median\",%csv_report$"}});
104 ADD_CASES(TC_CSVOut,
105 {{"^\"BM_ExplicitRepetitions/repeats:2_stddev\",%csv_report$"}});
107 // ========================================================================= //
108 // ------------------------ Testing Basic Output --------------------------- //
109 // ========================================================================= //
111 static void BM_ImplicitRepetitions(benchmark::State& state) {
112 for (auto _ : state) {
115 BENCHMARK(BM_ImplicitRepetitions);
117 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
118 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
119 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions %console_report$"}});
120 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_mean %console_report$"}});
121 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_median %console_report$"}});
122 ADD_CASES(TC_ConsoleOut, {{"^BM_ImplicitRepetitions_stddev %console_report$"}});
123 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
124 {"\"family_index\": 1,$", MR_Next},
125 {"\"per_family_instance_index\": 0,$", MR_Next},
126 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
127 {"\"run_type\": \"iteration\",$", MR_Next},
128 {"\"repetitions\": 3,$", MR_Next},
129 {"\"repetition_index\": 0,$", MR_Next},
130 {"\"threads\": 1,$", MR_Next},
131 {"\"iterations\": %int,$", MR_Next},
132 {"\"real_time\": %float,$", MR_Next},
133 {"\"cpu_time\": %float,$", MR_Next},
134 {"\"time_unit\": \"ns\"$", MR_Next},
135 {"}", MR_Next}});
136 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
137 {"\"family_index\": 1,$", MR_Next},
138 {"\"per_family_instance_index\": 0,$", MR_Next},
139 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
140 {"\"run_type\": \"iteration\",$", MR_Next},
141 {"\"repetitions\": 3,$", MR_Next},
142 {"\"repetition_index\": 1,$", MR_Next},
143 {"\"threads\": 1,$", MR_Next},
144 {"\"iterations\": %int,$", MR_Next},
145 {"\"real_time\": %float,$", MR_Next},
146 {"\"cpu_time\": %float,$", MR_Next},
147 {"\"time_unit\": \"ns\"$", MR_Next},
148 {"}", MR_Next}});
149 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions\",$"},
150 {"\"family_index\": 1,$", MR_Next},
151 {"\"per_family_instance_index\": 0,$", MR_Next},
152 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
153 {"\"run_type\": \"iteration\",$", MR_Next},
154 {"\"repetitions\": 3,$", MR_Next},
155 {"\"repetition_index\": 2,$", MR_Next},
156 {"\"threads\": 1,$", MR_Next},
157 {"\"iterations\": %int,$", MR_Next},
158 {"\"real_time\": %float,$", MR_Next},
159 {"\"cpu_time\": %float,$", MR_Next},
160 {"\"time_unit\": \"ns\"$", MR_Next},
161 {"}", MR_Next}});
162 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_mean\",$"},
163 {"\"family_index\": 1,$", MR_Next},
164 {"\"per_family_instance_index\": 0,$", MR_Next},
165 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
166 {"\"run_type\": \"aggregate\",$", MR_Next},
167 {"\"repetitions\": 3,$", MR_Next},
168 {"\"threads\": 1,$", MR_Next},
169 {"\"aggregate_name\": \"mean\",$", MR_Next},
170 {"\"aggregate_unit\": \"time\",$", MR_Next},
171 {"\"iterations\": %int,$", MR_Next},
172 {"\"real_time\": %float,$", MR_Next},
173 {"\"cpu_time\": %float,$", MR_Next},
174 {"\"time_unit\": \"ns\"$", MR_Next},
175 {"}", MR_Next}});
176 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_median\",$"},
177 {"\"family_index\": 1,$", MR_Next},
178 {"\"per_family_instance_index\": 0,$", MR_Next},
179 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
180 {"\"run_type\": \"aggregate\",$", MR_Next},
181 {"\"repetitions\": 3,$", MR_Next},
182 {"\"threads\": 1,$", MR_Next},
183 {"\"aggregate_name\": \"median\",$", MR_Next},
184 {"\"aggregate_unit\": \"time\",$", MR_Next},
185 {"\"iterations\": %int,$", MR_Next},
186 {"\"real_time\": %float,$", MR_Next},
187 {"\"cpu_time\": %float,$", MR_Next},
188 {"\"time_unit\": \"ns\"$", MR_Next},
189 {"}", MR_Next}});
190 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_ImplicitRepetitions_stddev\",$"},
191 {"\"family_index\": 1,$", MR_Next},
192 {"\"per_family_instance_index\": 0,$", MR_Next},
193 {"\"run_name\": \"BM_ImplicitRepetitions\",$", MR_Next},
194 {"\"run_type\": \"aggregate\",$", MR_Next},
195 {"\"repetitions\": 3,$", MR_Next},
196 {"\"threads\": 1,$", MR_Next},
197 {"\"aggregate_name\": \"stddev\",$", MR_Next},
198 {"\"aggregate_unit\": \"time\",$", MR_Next},
199 {"\"iterations\": %int,$", MR_Next},
200 {"\"real_time\": %float,$", MR_Next},
201 {"\"cpu_time\": %float,$", MR_Next},
202 {"\"time_unit\": \"ns\"$", MR_Next},
203 {"}", MR_Next}});
204 ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
205 ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions\",%csv_report$"}});
206 ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_mean\",%csv_report$"}});
207 ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_median\",%csv_report$"}});
208 ADD_CASES(TC_CSVOut, {{"^\"BM_ImplicitRepetitions_stddev\",%csv_report$"}});
210 // ========================================================================= //
211 // --------------------------- TEST CASES END ------------------------------ //
212 // ========================================================================= //
214 int main(int argc, char* argv[]) { RunOutputTests(argc, argv); }