1 
2 #undef NDEBUG
3 
4 #include "benchmark/benchmark.h"
5 #include "output_test.h"
6 
7 // ========================================================================= //
8 // ---------------------- Testing Prologue Output -------------------------- //
9 // ========================================================================= //
10 
11 // clang-format off
12 
13 ADD_CASES(TC_ConsoleOut,
14           {{"^[-]+$", MR_Next},
15            {"^Benchmark %s Time %s CPU %s Iterations UserCounters...$", MR_Next},
16            {"^[-]+$", MR_Next}});
17 ADD_CASES(TC_CSVOut, {{"%csv_header,\"bar\",\"foo\""}});
18 
19 // clang-format on
20 
21 // ========================================================================= //
22 // ------------------------- Simple Counters Output ------------------------ //
23 // ========================================================================= //
24 
BM_Counters_Simple(benchmark::State & state)25 void BM_Counters_Simple(benchmark::State& state) {
26   for (auto _ : state) {
27   }
28   state.counters["foo"] = 1;
29   state.counters["bar"] = 2 * (double)state.iterations();
30 }
31 BENCHMARK(BM_Counters_Simple);
32 ADD_CASES(TC_ConsoleOut,
33           {{"^BM_Counters_Simple %console_report bar=%hrfloat foo=%hrfloat$"}});
34 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Simple\",$"},
35                        {"\"run_name\": \"BM_Counters_Simple\",$", MR_Next},
36                        {"\"run_type\": \"iteration\",$", MR_Next},
37                        {"\"repetitions\": 0,$", MR_Next},
38                        {"\"repetition_index\": 0,$", MR_Next},
39                        {"\"threads\": 1,$", MR_Next},
40                        {"\"iterations\": %int,$", MR_Next},
41                        {"\"real_time\": %float,$", MR_Next},
42                        {"\"cpu_time\": %float,$", MR_Next},
43                        {"\"time_unit\": \"ns\",$", MR_Next},
44                        {"\"bar\": %float,$", MR_Next},
45                        {"\"foo\": %float$", MR_Next},
46                        {"}", MR_Next}});
47 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_Simple\",%csv_report,%float,%float$"}});
48 // VS2013 does not allow this function to be passed as a lambda argument
49 // to CHECK_BENCHMARK_RESULTS()
CheckSimple(Results const & e)50 void CheckSimple(Results const& e) {
51   double its = e.NumIterations();
52   CHECK_COUNTER_VALUE(e, int, "foo", EQ, 1);
53   // check that the value of bar is within 0.1% of the expected value
54   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. * its, 0.001);
55 }
56 CHECK_BENCHMARK_RESULTS("BM_Counters_Simple", &CheckSimple);
57 
58 // ========================================================================= //
59 // --------------------- Counters+Items+Bytes/s Output --------------------- //
60 // ========================================================================= //
61 
62 namespace {
63 int num_calls1 = 0;
64 }
BM_Counters_WithBytesAndItemsPSec(benchmark::State & state)65 void BM_Counters_WithBytesAndItemsPSec(benchmark::State& state) {
66   for (auto _ : state) {
67   }
68   state.counters["foo"] = 1;
69   state.counters["bar"] = ++num_calls1;
70   state.SetBytesProcessed(364);
71   state.SetItemsProcessed(150);
72 }
73 BENCHMARK(BM_Counters_WithBytesAndItemsPSec);
74 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_WithBytesAndItemsPSec %console_report "
75                            "bar=%hrfloat bytes_per_second=%hrfloat/s "
76                            "foo=%hrfloat items_per_second=%hrfloat/s$"}});
77 ADD_CASES(TC_JSONOut,
78           {{"\"name\": \"BM_Counters_WithBytesAndItemsPSec\",$"},
79            {"\"run_name\": \"BM_Counters_WithBytesAndItemsPSec\",$", MR_Next},
80            {"\"run_type\": \"iteration\",$", MR_Next},
81            {"\"repetitions\": 0,$", MR_Next},
82            {"\"repetition_index\": 0,$", MR_Next},
83            {"\"threads\": 1,$", MR_Next},
84            {"\"iterations\": %int,$", MR_Next},
85            {"\"real_time\": %float,$", MR_Next},
86            {"\"cpu_time\": %float,$", MR_Next},
87            {"\"time_unit\": \"ns\",$", MR_Next},
88            {"\"bar\": %float,$", MR_Next},
89            {"\"bytes_per_second\": %float,$", MR_Next},
90            {"\"foo\": %float,$", MR_Next},
91            {"\"items_per_second\": %float$", MR_Next},
92            {"}", MR_Next}});
93 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_WithBytesAndItemsPSec\","
94                        "%csv_bytes_items_report,%float,%float$"}});
95 // VS2013 does not allow this function to be passed as a lambda argument
96 // to CHECK_BENCHMARK_RESULTS()
CheckBytesAndItemsPSec(Results const & e)97 void CheckBytesAndItemsPSec(Results const& e) {
98   double t = e.DurationCPUTime();  // this (and not real time) is the time used
99   CHECK_COUNTER_VALUE(e, int, "foo", EQ, 1);
100   CHECK_COUNTER_VALUE(e, int, "bar", EQ, num_calls1);
101   // check that the values are within 0.1% of the expected values
102   CHECK_FLOAT_RESULT_VALUE(e, "bytes_per_second", EQ, 364. / t, 0.001);
103   CHECK_FLOAT_RESULT_VALUE(e, "items_per_second", EQ, 150. / t, 0.001);
104 }
105 CHECK_BENCHMARK_RESULTS("BM_Counters_WithBytesAndItemsPSec",
106                         &CheckBytesAndItemsPSec);
107 
108 // ========================================================================= //
109 // ------------------------- Rate Counters Output -------------------------- //
110 // ========================================================================= //
111 
BM_Counters_Rate(benchmark::State & state)112 void BM_Counters_Rate(benchmark::State& state) {
113   for (auto _ : state) {
114   }
115   namespace bm = benchmark;
116   state.counters["foo"] = bm::Counter{1, bm::Counter::kIsRate};
117   state.counters["bar"] = bm::Counter{2, bm::Counter::kIsRate};
118 }
119 BENCHMARK(BM_Counters_Rate);
120 ADD_CASES(
121     TC_ConsoleOut,
122     {{"^BM_Counters_Rate %console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
123 ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Counters_Rate\",$"},
124                        {"\"run_name\": \"BM_Counters_Rate\",$", MR_Next},
125                        {"\"run_type\": \"iteration\",$", MR_Next},
126                        {"\"repetitions\": 0,$", MR_Next},
127                        {"\"repetition_index\": 0,$", MR_Next},
128                        {"\"threads\": 1,$", MR_Next},
129                        {"\"iterations\": %int,$", MR_Next},
130                        {"\"real_time\": %float,$", MR_Next},
131                        {"\"cpu_time\": %float,$", MR_Next},
132                        {"\"time_unit\": \"ns\",$", MR_Next},
133                        {"\"bar\": %float,$", MR_Next},
134                        {"\"foo\": %float$", MR_Next},
135                        {"}", MR_Next}});
136 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_Rate\",%csv_report,%float,%float$"}});
137 // VS2013 does not allow this function to be passed as a lambda argument
138 // to CHECK_BENCHMARK_RESULTS()
CheckRate(Results const & e)139 void CheckRate(Results const& e) {
140   double t = e.DurationCPUTime();  // this (and not real time) is the time used
141   // check that the values are within 0.1% of the expected values
142   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, 1. / t, 0.001);
143   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. / t, 0.001);
144 }
145 CHECK_BENCHMARK_RESULTS("BM_Counters_Rate", &CheckRate);
146 
147 // ========================================================================= //
148 // ------------------------- Thread Counters Output ------------------------ //
149 // ========================================================================= //
150 
BM_Counters_Threads(benchmark::State & state)151 void BM_Counters_Threads(benchmark::State& state) {
152   for (auto _ : state) {
153   }
154   state.counters["foo"] = 1;
155   state.counters["bar"] = 2;
156 }
157 BENCHMARK(BM_Counters_Threads)->ThreadRange(1, 8);
158 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_Threads/threads:%int %console_report "
159                            "bar=%hrfloat foo=%hrfloat$"}});
160 ADD_CASES(TC_JSONOut,
161           {{"\"name\": \"BM_Counters_Threads/threads:%int\",$"},
162            {"\"run_name\": \"BM_Counters_Threads/threads:%int\",$", MR_Next},
163            {"\"run_type\": \"iteration\",$", MR_Next},
164            {"\"repetitions\": 0,$", MR_Next},
165            {"\"repetition_index\": 0,$", MR_Next},
166            {"\"threads\": 1,$", MR_Next},
167            {"\"iterations\": %int,$", MR_Next},
168            {"\"real_time\": %float,$", MR_Next},
169            {"\"cpu_time\": %float,$", MR_Next},
170            {"\"time_unit\": \"ns\",$", MR_Next},
171            {"\"bar\": %float,$", MR_Next},
172            {"\"foo\": %float$", MR_Next},
173            {"}", MR_Next}});
174 ADD_CASES(
175     TC_CSVOut,
176     {{"^\"BM_Counters_Threads/threads:%int\",%csv_report,%float,%float$"}});
177 // VS2013 does not allow this function to be passed as a lambda argument
178 // to CHECK_BENCHMARK_RESULTS()
CheckThreads(Results const & e)179 void CheckThreads(Results const& e) {
180   CHECK_COUNTER_VALUE(e, int, "foo", EQ, e.NumThreads());
181   CHECK_COUNTER_VALUE(e, int, "bar", EQ, 2 * e.NumThreads());
182 }
183 CHECK_BENCHMARK_RESULTS("BM_Counters_Threads/threads:%int", &CheckThreads);
184 
185 // ========================================================================= //
186 // ---------------------- ThreadAvg Counters Output ------------------------ //
187 // ========================================================================= //
188 
BM_Counters_AvgThreads(benchmark::State & state)189 void BM_Counters_AvgThreads(benchmark::State& state) {
190   for (auto _ : state) {
191   }
192   namespace bm = benchmark;
193   state.counters["foo"] = bm::Counter{1, bm::Counter::kAvgThreads};
194   state.counters["bar"] = bm::Counter{2, bm::Counter::kAvgThreads};
195 }
196 BENCHMARK(BM_Counters_AvgThreads)->ThreadRange(1, 8);
197 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_AvgThreads/threads:%int "
198                            "%console_report bar=%hrfloat foo=%hrfloat$"}});
199 ADD_CASES(TC_JSONOut,
200           {{"\"name\": \"BM_Counters_AvgThreads/threads:%int\",$"},
201            {"\"run_name\": \"BM_Counters_AvgThreads/threads:%int\",$", MR_Next},
202            {"\"run_type\": \"iteration\",$", MR_Next},
203            {"\"repetitions\": 0,$", MR_Next},
204            {"\"repetition_index\": 0,$", MR_Next},
205            {"\"threads\": 1,$", MR_Next},
206            {"\"iterations\": %int,$", MR_Next},
207            {"\"real_time\": %float,$", MR_Next},
208            {"\"cpu_time\": %float,$", MR_Next},
209            {"\"time_unit\": \"ns\",$", MR_Next},
210            {"\"bar\": %float,$", MR_Next},
211            {"\"foo\": %float$", MR_Next},
212            {"}", MR_Next}});
213 ADD_CASES(
214     TC_CSVOut,
215     {{"^\"BM_Counters_AvgThreads/threads:%int\",%csv_report,%float,%float$"}});
216 // VS2013 does not allow this function to be passed as a lambda argument
217 // to CHECK_BENCHMARK_RESULTS()
CheckAvgThreads(Results const & e)218 void CheckAvgThreads(Results const& e) {
219   CHECK_COUNTER_VALUE(e, int, "foo", EQ, 1);
220   CHECK_COUNTER_VALUE(e, int, "bar", EQ, 2);
221 }
222 CHECK_BENCHMARK_RESULTS("BM_Counters_AvgThreads/threads:%int",
223                         &CheckAvgThreads);
224 
225 // ========================================================================= //
226 // ---------------------- ThreadAvg Counters Output ------------------------ //
227 // ========================================================================= //
228 
BM_Counters_AvgThreadsRate(benchmark::State & state)229 void BM_Counters_AvgThreadsRate(benchmark::State& state) {
230   for (auto _ : state) {
231   }
232   namespace bm = benchmark;
233   state.counters["foo"] = bm::Counter{1, bm::Counter::kAvgThreadsRate};
234   state.counters["bar"] = bm::Counter{2, bm::Counter::kAvgThreadsRate};
235 }
236 BENCHMARK(BM_Counters_AvgThreadsRate)->ThreadRange(1, 8);
237 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_AvgThreadsRate/threads:%int "
238                            "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
239 ADD_CASES(TC_JSONOut,
240           {{"\"name\": \"BM_Counters_AvgThreadsRate/threads:%int\",$"},
241            {"\"run_name\": \"BM_Counters_AvgThreadsRate/threads:%int\",$",
242             MR_Next},
243            {"\"run_type\": \"iteration\",$", MR_Next},
244            {"\"repetitions\": 0,$", MR_Next},
245            {"\"repetition_index\": 0,$", MR_Next},
246            {"\"threads\": 1,$", MR_Next},
247            {"\"iterations\": %int,$", MR_Next},
248            {"\"real_time\": %float,$", MR_Next},
249            {"\"cpu_time\": %float,$", MR_Next},
250            {"\"time_unit\": \"ns\",$", MR_Next},
251            {"\"bar\": %float,$", MR_Next},
252            {"\"foo\": %float$", MR_Next},
253            {"}", MR_Next}});
254 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_AvgThreadsRate/"
255                        "threads:%int\",%csv_report,%float,%float$"}});
256 // VS2013 does not allow this function to be passed as a lambda argument
257 // to CHECK_BENCHMARK_RESULTS()
CheckAvgThreadsRate(Results const & e)258 void CheckAvgThreadsRate(Results const& e) {
259   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, 1. / e.DurationCPUTime(), 0.001);
260   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. / e.DurationCPUTime(), 0.001);
261 }
262 CHECK_BENCHMARK_RESULTS("BM_Counters_AvgThreadsRate/threads:%int",
263                         &CheckAvgThreadsRate);
264 
265 // ========================================================================= //
266 // ------------------- IterationInvariant Counters Output ------------------ //
267 // ========================================================================= //
268 
BM_Counters_IterationInvariant(benchmark::State & state)269 void BM_Counters_IterationInvariant(benchmark::State& state) {
270   for (auto _ : state) {
271   }
272   namespace bm = benchmark;
273   state.counters["foo"] = bm::Counter{1, bm::Counter::kIsIterationInvariant};
274   state.counters["bar"] = bm::Counter{2, bm::Counter::kIsIterationInvariant};
275 }
276 BENCHMARK(BM_Counters_IterationInvariant);
277 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_IterationInvariant %console_report "
278                            "bar=%hrfloat foo=%hrfloat$"}});
279 ADD_CASES(TC_JSONOut,
280           {{"\"name\": \"BM_Counters_IterationInvariant\",$"},
281            {"\"run_name\": \"BM_Counters_IterationInvariant\",$", MR_Next},
282            {"\"run_type\": \"iteration\",$", MR_Next},
283            {"\"repetitions\": 0,$", MR_Next},
284            {"\"repetition_index\": 0,$", MR_Next},
285            {"\"threads\": 1,$", MR_Next},
286            {"\"iterations\": %int,$", MR_Next},
287            {"\"real_time\": %float,$", MR_Next},
288            {"\"cpu_time\": %float,$", MR_Next},
289            {"\"time_unit\": \"ns\",$", MR_Next},
290            {"\"bar\": %float,$", MR_Next},
291            {"\"foo\": %float$", MR_Next},
292            {"}", MR_Next}});
293 ADD_CASES(TC_CSVOut,
294           {{"^\"BM_Counters_IterationInvariant\",%csv_report,%float,%float$"}});
295 // VS2013 does not allow this function to be passed as a lambda argument
296 // to CHECK_BENCHMARK_RESULTS()
CheckIterationInvariant(Results const & e)297 void CheckIterationInvariant(Results const& e) {
298   double its = e.NumIterations();
299   // check that the values are within 0.1% of the expected value
300   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, its, 0.001);
301   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. * its, 0.001);
302 }
303 CHECK_BENCHMARK_RESULTS("BM_Counters_IterationInvariant",
304                         &CheckIterationInvariant);
305 
306 // ========================================================================= //
307 // ----------------- IterationInvariantRate Counters Output ---------------- //
308 // ========================================================================= //
309 
BM_Counters_kIsIterationInvariantRate(benchmark::State & state)310 void BM_Counters_kIsIterationInvariantRate(benchmark::State& state) {
311   for (auto _ : state) {
312   }
313   namespace bm = benchmark;
314   state.counters["foo"] =
315       bm::Counter{1, bm::Counter::kIsIterationInvariantRate};
316   state.counters["bar"] =
317       bm::Counter{2, bm::Counter::kIsRate | bm::Counter::kIsIterationInvariant};
318 }
319 BENCHMARK(BM_Counters_kIsIterationInvariantRate);
320 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_kIsIterationInvariantRate "
321                            "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
322 ADD_CASES(TC_JSONOut,
323           {{"\"name\": \"BM_Counters_kIsIterationInvariantRate\",$"},
324            {"\"run_name\": \"BM_Counters_kIsIterationInvariantRate\",$",
325             MR_Next},
326            {"\"run_type\": \"iteration\",$", MR_Next},
327            {"\"repetitions\": 0,$", MR_Next},
328            {"\"repetition_index\": 0,$", MR_Next},
329            {"\"threads\": 1,$", MR_Next},
330            {"\"iterations\": %int,$", MR_Next},
331            {"\"real_time\": %float,$", MR_Next},
332            {"\"cpu_time\": %float,$", MR_Next},
333            {"\"time_unit\": \"ns\",$", MR_Next},
334            {"\"bar\": %float,$", MR_Next},
335            {"\"foo\": %float$", MR_Next},
336            {"}", MR_Next}});
337 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_kIsIterationInvariantRate\",%csv_report,"
338                        "%float,%float$"}});
339 // VS2013 does not allow this function to be passed as a lambda argument
340 // to CHECK_BENCHMARK_RESULTS()
CheckIsIterationInvariantRate(Results const & e)341 void CheckIsIterationInvariantRate(Results const& e) {
342   double its = e.NumIterations();
343   double t = e.DurationCPUTime();  // this (and not real time) is the time used
344   // check that the values are within 0.1% of the expected values
345   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, its * 1. / t, 0.001);
346   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, its * 2. / t, 0.001);
347 }
348 CHECK_BENCHMARK_RESULTS("BM_Counters_kIsIterationInvariantRate",
349                         &CheckIsIterationInvariantRate);
350 
351 // ========================================================================= //
352 // ------------------- AvgIterations Counters Output ------------------ //
353 // ========================================================================= //
354 
BM_Counters_AvgIterations(benchmark::State & state)355 void BM_Counters_AvgIterations(benchmark::State& state) {
356   for (auto _ : state) {
357   }
358   namespace bm = benchmark;
359   state.counters["foo"] = bm::Counter{1, bm::Counter::kAvgIterations};
360   state.counters["bar"] = bm::Counter{2, bm::Counter::kAvgIterations};
361 }
362 BENCHMARK(BM_Counters_AvgIterations);
363 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_AvgIterations %console_report "
364                            "bar=%hrfloat foo=%hrfloat$"}});
365 ADD_CASES(TC_JSONOut,
366           {{"\"name\": \"BM_Counters_AvgIterations\",$"},
367            {"\"run_name\": \"BM_Counters_AvgIterations\",$", MR_Next},
368            {"\"run_type\": \"iteration\",$", MR_Next},
369            {"\"repetitions\": 0,$", MR_Next},
370            {"\"repetition_index\": 0,$", MR_Next},
371            {"\"threads\": 1,$", MR_Next},
372            {"\"iterations\": %int,$", MR_Next},
373            {"\"real_time\": %float,$", MR_Next},
374            {"\"cpu_time\": %float,$", MR_Next},
375            {"\"time_unit\": \"ns\",$", MR_Next},
376            {"\"bar\": %float,$", MR_Next},
377            {"\"foo\": %float$", MR_Next},
378            {"}", MR_Next}});
379 ADD_CASES(TC_CSVOut,
380           {{"^\"BM_Counters_AvgIterations\",%csv_report,%float,%float$"}});
381 // VS2013 does not allow this function to be passed as a lambda argument
382 // to CHECK_BENCHMARK_RESULTS()
CheckAvgIterations(Results const & e)383 void CheckAvgIterations(Results const& e) {
384   double its = e.NumIterations();
385   // check that the values are within 0.1% of the expected value
386   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, 1. / its, 0.001);
387   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. / its, 0.001);
388 }
389 CHECK_BENCHMARK_RESULTS("BM_Counters_AvgIterations", &CheckAvgIterations);
390 
391 // ========================================================================= //
392 // ----------------- AvgIterationsRate Counters Output ---------------- //
393 // ========================================================================= //
394 
BM_Counters_kAvgIterationsRate(benchmark::State & state)395 void BM_Counters_kAvgIterationsRate(benchmark::State& state) {
396   for (auto _ : state) {
397   }
398   namespace bm = benchmark;
399   state.counters["foo"] = bm::Counter{1, bm::Counter::kAvgIterationsRate};
400   state.counters["bar"] =
401       bm::Counter{2, bm::Counter::kIsRate | bm::Counter::kAvgIterations};
402 }
403 BENCHMARK(BM_Counters_kAvgIterationsRate);
404 ADD_CASES(TC_ConsoleOut, {{"^BM_Counters_kAvgIterationsRate "
405                            "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
406 ADD_CASES(TC_JSONOut,
407           {{"\"name\": \"BM_Counters_kAvgIterationsRate\",$"},
408            {"\"run_name\": \"BM_Counters_kAvgIterationsRate\",$", MR_Next},
409            {"\"run_type\": \"iteration\",$", MR_Next},
410            {"\"repetitions\": 0,$", MR_Next},
411            {"\"repetition_index\": 0,$", MR_Next},
412            {"\"threads\": 1,$", MR_Next},
413            {"\"iterations\": %int,$", MR_Next},
414            {"\"real_time\": %float,$", MR_Next},
415            {"\"cpu_time\": %float,$", MR_Next},
416            {"\"time_unit\": \"ns\",$", MR_Next},
417            {"\"bar\": %float,$", MR_Next},
418            {"\"foo\": %float$", MR_Next},
419            {"}", MR_Next}});
420 ADD_CASES(TC_CSVOut, {{"^\"BM_Counters_kAvgIterationsRate\",%csv_report,"
421                        "%float,%float$"}});
422 // VS2013 does not allow this function to be passed as a lambda argument
423 // to CHECK_BENCHMARK_RESULTS()
CheckAvgIterationsRate(Results const & e)424 void CheckAvgIterationsRate(Results const& e) {
425   double its = e.NumIterations();
426   double t = e.DurationCPUTime();  // this (and not real time) is the time used
427   // check that the values are within 0.1% of the expected values
428   CHECK_FLOAT_COUNTER_VALUE(e, "foo", EQ, 1. / its / t, 0.001);
429   CHECK_FLOAT_COUNTER_VALUE(e, "bar", EQ, 2. / its / t, 0.001);
430 }
431 CHECK_BENCHMARK_RESULTS("BM_Counters_kAvgIterationsRate",
432                         &CheckAvgIterationsRate);
433 
434 // ========================================================================= //
435 // --------------------------- TEST CASES END ------------------------------ //
436 // ========================================================================= //
437 
main(int argc,char * argv[])438 int main(int argc, char* argv[]) { RunOutputTests(argc, argv); }
439