Go to the documentation of this file.
4 #include "benchmark/benchmark.h"
15 {
"^Benchmark %s Time %s CPU %s Iterations UserCounters...$",
MR_Next},
28 state.counters[
"foo"] = 1;
29 state.counters[
"bar"] = 2 * (double)
state.iterations();
33 {{
"^BM_Counters_Simple %console_report bar=%hrfloat foo=%hrfloat$"}});
35 {
"\"family_index\": 0,$",
MR_Next},
36 {
"\"per_family_instance_index\": 0,$",
MR_Next},
37 {
"\"run_name\": \"BM_Counters_Simple\",$",
MR_Next},
38 {
"\"run_type\": \"iteration\",$",
MR_Next},
39 {
"\"repetitions\": 1,$",
MR_Next},
40 {
"\"repetition_index\": 0,$",
MR_Next},
42 {
"\"iterations\": %int,$",
MR_Next},
43 {
"\"real_time\": %float,$",
MR_Next},
44 {
"\"cpu_time\": %float,$",
MR_Next},
45 {
"\"time_unit\": \"ns\",$",
MR_Next},
53 double its = e.NumIterations();
72 state.counters[
"foo"] = 1;
73 state.counters[
"bar"] = ++num_calls1;
74 state.SetBytesProcessed(364);
75 state.SetItemsProcessed(150);
79 "bar=%hrfloat bytes_per_second=%hrfloat/s "
80 "foo=%hrfloat items_per_second=%hrfloat/s$"}});
82 {{
"\"name\": \"BM_Counters_WithBytesAndItemsPSec\",$"},
83 {
"\"family_index\": 1,$",
MR_Next},
84 {
"\"per_family_instance_index\": 0,$",
MR_Next},
85 {
"\"run_name\": \"BM_Counters_WithBytesAndItemsPSec\",$",
MR_Next},
86 {
"\"run_type\": \"iteration\",$",
MR_Next},
87 {
"\"repetitions\": 1,$",
MR_Next},
88 {
"\"repetition_index\": 0,$",
MR_Next},
90 {
"\"iterations\": %int,$",
MR_Next},
91 {
"\"real_time\": %float,$",
MR_Next},
92 {
"\"cpu_time\": %float,$",
MR_Next},
93 {
"\"time_unit\": \"ns\",$",
MR_Next},
95 {
"\"bytes_per_second\": %float,$",
MR_Next},
97 {
"\"items_per_second\": %float$",
MR_Next},
100 "%csv_bytes_items_report,%float,%float$"}});
104 double t = e.DurationCPUTime();
124 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kIsRate};
125 state.counters[
"bar"] = bm::Counter{2, bm::Counter::kIsRate};
130 {{
"^BM_Counters_Rate %console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
132 {
"\"family_index\": 2,$",
MR_Next},
133 {
"\"per_family_instance_index\": 0,$",
MR_Next},
134 {
"\"run_name\": \"BM_Counters_Rate\",$",
MR_Next},
135 {
"\"run_type\": \"iteration\",$",
MR_Next},
136 {
"\"repetitions\": 1,$",
MR_Next},
137 {
"\"repetition_index\": 0,$",
MR_Next},
139 {
"\"iterations\": %int,$",
MR_Next},
140 {
"\"real_time\": %float,$",
MR_Next},
141 {
"\"cpu_time\": %float,$",
MR_Next},
142 {
"\"time_unit\": \"ns\",$",
MR_Next},
143 {
"\"bar\": %float,$",
MR_Next},
150 double t = e.DurationCPUTime();
167 state.counters[
"foo"] = bm::Counter{0.0001, bm::Counter::kInvert};
168 state.counters[
"bar"] = bm::Counter{10000, bm::Counter::kInvert};
172 {{
"^BM_Invert %console_report bar=%hrfloatu foo=%hrfloatk$"}});
174 {
"\"family_index\": 3,$",
MR_Next},
175 {
"\"per_family_instance_index\": 0,$",
MR_Next},
176 {
"\"run_name\": \"BM_Invert\",$",
MR_Next},
177 {
"\"run_type\": \"iteration\",$",
MR_Next},
178 {
"\"repetitions\": 1,$",
MR_Next},
179 {
"\"repetition_index\": 0,$",
MR_Next},
181 {
"\"iterations\": %int,$",
MR_Next},
182 {
"\"real_time\": %float,$",
MR_Next},
183 {
"\"cpu_time\": %float,$",
MR_Next},
184 {
"\"time_unit\": \"ns\",$",
MR_Next},
185 {
"\"bar\": %float,$",
MR_Next},
208 state.counters[
"foo"] =
209 bm::Counter{1, bm::Counter::kIsRate | bm::Counter::kInvert};
210 state.counters[
"bar"] =
211 bm::Counter{8192, bm::Counter::kIsRate | bm::Counter::kInvert};
215 "bar=%hrfloats foo=%hrfloats$"}});
217 {{
"\"name\": \"BM_Counters_InvertedRate\",$"},
218 {
"\"family_index\": 4,$",
MR_Next},
219 {
"\"per_family_instance_index\": 0,$",
MR_Next},
220 {
"\"run_name\": \"BM_Counters_InvertedRate\",$",
MR_Next},
221 {
"\"run_type\": \"iteration\",$",
MR_Next},
222 {
"\"repetitions\": 1,$",
MR_Next},
223 {
"\"repetition_index\": 0,$",
MR_Next},
225 {
"\"iterations\": %int,$",
MR_Next},
226 {
"\"real_time\": %float,$",
MR_Next},
227 {
"\"cpu_time\": %float,$",
MR_Next},
228 {
"\"time_unit\": \"ns\",$",
MR_Next},
229 {
"\"bar\": %float,$",
MR_Next},
233 {{
"^\"BM_Counters_InvertedRate\",%csv_report,%float,%float$"}});
237 double t = e.DurationCPUTime();
251 state.counters[
"foo"] = 1;
252 state.counters[
"bar"] = 2;
256 "bar=%hrfloat foo=%hrfloat$"}});
258 {{
"\"name\": \"BM_Counters_Threads/threads:%int\",$"},
259 {
"\"family_index\": 5,$",
MR_Next},
260 {
"\"per_family_instance_index\": 0,$",
MR_Next},
261 {
"\"run_name\": \"BM_Counters_Threads/threads:%int\",$",
MR_Next},
262 {
"\"run_type\": \"iteration\",$",
MR_Next},
263 {
"\"repetitions\": 1,$",
MR_Next},
264 {
"\"repetition_index\": 0,$",
MR_Next},
266 {
"\"iterations\": %int,$",
MR_Next},
267 {
"\"real_time\": %float,$",
MR_Next},
268 {
"\"cpu_time\": %float,$",
MR_Next},
269 {
"\"time_unit\": \"ns\",$",
MR_Next},
270 {
"\"bar\": %float,$",
MR_Next},
275 {{
"^\"BM_Counters_Threads/threads:%int\",%csv_report,%float,%float$"}});
292 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kAvgThreads};
293 state.counters[
"bar"] = bm::Counter{2, bm::Counter::kAvgThreads};
297 "%console_report bar=%hrfloat foo=%hrfloat$"}});
299 {{
"\"name\": \"BM_Counters_AvgThreads/threads:%int\",$"},
300 {
"\"family_index\": 6,$",
MR_Next},
301 {
"\"per_family_instance_index\": 0,$",
MR_Next},
302 {
"\"run_name\": \"BM_Counters_AvgThreads/threads:%int\",$",
MR_Next},
303 {
"\"run_type\": \"iteration\",$",
MR_Next},
304 {
"\"repetitions\": 1,$",
MR_Next},
305 {
"\"repetition_index\": 0,$",
MR_Next},
307 {
"\"iterations\": %int,$",
MR_Next},
308 {
"\"real_time\": %float,$",
MR_Next},
309 {
"\"cpu_time\": %float,$",
MR_Next},
310 {
"\"time_unit\": \"ns\",$",
MR_Next},
311 {
"\"bar\": %float,$",
MR_Next},
316 {{
"^\"BM_Counters_AvgThreads/threads:%int\",%csv_report,%float,%float$"}});
336 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kAvgThreadsRate};
337 state.counters[
"bar"] = bm::Counter{2, bm::Counter::kAvgThreadsRate};
341 "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
343 {{
"\"name\": \"BM_Counters_AvgThreadsRate/threads:%int\",$"},
344 {
"\"family_index\": 7,$",
MR_Next},
345 {
"\"per_family_instance_index\": 0,$",
MR_Next},
346 {
"\"run_name\": \"BM_Counters_AvgThreadsRate/threads:%int\",$",
348 {
"\"run_type\": \"iteration\",$",
MR_Next},
349 {
"\"repetitions\": 1,$",
MR_Next},
350 {
"\"repetition_index\": 0,$",
MR_Next},
352 {
"\"iterations\": %int,$",
MR_Next},
353 {
"\"real_time\": %float,$",
MR_Next},
354 {
"\"cpu_time\": %float,$",
MR_Next},
355 {
"\"time_unit\": \"ns\",$",
MR_Next},
356 {
"\"bar\": %float,$",
MR_Next},
360 "threads:%int\",%csv_report,%float,%float$"}});
378 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kIsIterationInvariant};
379 state.counters[
"bar"] = bm::Counter{2, bm::Counter::kIsIterationInvariant};
383 "bar=%hrfloat foo=%hrfloat$"}});
385 {{
"\"name\": \"BM_Counters_IterationInvariant\",$"},
386 {
"\"family_index\": 8,$",
MR_Next},
387 {
"\"per_family_instance_index\": 0,$",
MR_Next},
388 {
"\"run_name\": \"BM_Counters_IterationInvariant\",$",
MR_Next},
389 {
"\"run_type\": \"iteration\",$",
MR_Next},
390 {
"\"repetitions\": 1,$",
MR_Next},
391 {
"\"repetition_index\": 0,$",
MR_Next},
393 {
"\"iterations\": %int,$",
MR_Next},
394 {
"\"real_time\": %float,$",
MR_Next},
395 {
"\"cpu_time\": %float,$",
MR_Next},
396 {
"\"time_unit\": \"ns\",$",
MR_Next},
397 {
"\"bar\": %float,$",
MR_Next},
401 {{
"^\"BM_Counters_IterationInvariant\",%csv_report,%float,%float$"}});
405 double its = e.NumIterations();
423 state.counters[
"foo"] =
424 bm::Counter{1, bm::Counter::kIsIterationInvariantRate};
425 state.counters[
"bar"] =
426 bm::Counter{2, bm::Counter::kIsRate | bm::Counter::kIsIterationInvariant};
430 "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
432 {{
"\"name\": \"BM_Counters_kIsIterationInvariantRate\",$"},
433 {
"\"family_index\": 9,$",
MR_Next},
434 {
"\"per_family_instance_index\": 0,$",
MR_Next},
435 {
"\"run_name\": \"BM_Counters_kIsIterationInvariantRate\",$",
437 {
"\"run_type\": \"iteration\",$",
MR_Next},
438 {
"\"repetitions\": 1,$",
MR_Next},
439 {
"\"repetition_index\": 0,$",
MR_Next},
441 {
"\"iterations\": %int,$",
MR_Next},
442 {
"\"real_time\": %float,$",
MR_Next},
443 {
"\"cpu_time\": %float,$",
MR_Next},
444 {
"\"time_unit\": \"ns\",$",
MR_Next},
445 {
"\"bar\": %float,$",
MR_Next},
453 double its = e.NumIterations();
454 double t = e.DurationCPUTime();
470 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kAvgIterations};
471 state.counters[
"bar"] = bm::Counter{2, bm::Counter::kAvgIterations};
475 "bar=%hrfloat foo=%hrfloat$"}});
477 {{
"\"name\": \"BM_Counters_AvgIterations\",$"},
478 {
"\"family_index\": 10,$",
MR_Next},
479 {
"\"per_family_instance_index\": 0,$",
MR_Next},
480 {
"\"run_name\": \"BM_Counters_AvgIterations\",$",
MR_Next},
481 {
"\"run_type\": \"iteration\",$",
MR_Next},
482 {
"\"repetitions\": 1,$",
MR_Next},
483 {
"\"repetition_index\": 0,$",
MR_Next},
485 {
"\"iterations\": %int,$",
MR_Next},
486 {
"\"real_time\": %float,$",
MR_Next},
487 {
"\"cpu_time\": %float,$",
MR_Next},
488 {
"\"time_unit\": \"ns\",$",
MR_Next},
489 {
"\"bar\": %float,$",
MR_Next},
493 {{
"^\"BM_Counters_AvgIterations\",%csv_report,%float,%float$"}});
497 double its = e.NumIterations();
514 state.counters[
"foo"] = bm::Counter{1, bm::Counter::kAvgIterationsRate};
515 state.counters[
"bar"] =
516 bm::Counter{2, bm::Counter::kIsRate | bm::Counter::kAvgIterations};
520 "%console_report bar=%hrfloat/s foo=%hrfloat/s$"}});
522 {{
"\"name\": \"BM_Counters_kAvgIterationsRate\",$"},
523 {
"\"family_index\": 11,$",
MR_Next},
524 {
"\"per_family_instance_index\": 0,$",
MR_Next},
525 {
"\"run_name\": \"BM_Counters_kAvgIterationsRate\",$",
MR_Next},
526 {
"\"run_type\": \"iteration\",$",
MR_Next},
527 {
"\"repetitions\": 1,$",
MR_Next},
528 {
"\"repetition_index\": 0,$",
MR_Next},
530 {
"\"iterations\": %int,$",
MR_Next},
531 {
"\"real_time\": %float,$",
MR_Next},
532 {
"\"cpu_time\": %float,$",
MR_Next},
533 {
"\"time_unit\": \"ns\",$",
MR_Next},
534 {
"\"bar\": %float,$",
MR_Next},
542 double its = e.NumIterations();
543 double t = e.DurationCPUTime();
void CheckIsIterationInvariantRate(Results const &e)
BENCHMARK(BM_Counters_Simple)
void CheckAvgThreadsRate(Results const &e)
void BM_Counters_AvgThreadsRate(benchmark::State &state)
void CheckInvertedRate(Results const &e)
BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const &value)
CHECK_BENCHMARK_RESULTS("BM_Counters_Simple", &CheckSimple)
void CheckInvert(Results const &e)
void CheckAvgThreads(Results const &e)
#define CHECK_FLOAT_RESULT_VALUE(entry, var_name, relationship, value, eps_factor)
void BM_Counters_kIsIterationInvariantRate(benchmark::State &state)
void BM_Counters_InvertedRate(benchmark::State &state)
void CheckThreads(Results const &e)
void BM_Counters_kAvgIterationsRate(benchmark::State &state)
void BM_Counters_AvgIterations(benchmark::State &state)
ADD_CASES(TC_ConsoleOut, {{"^[-]+$", MR_Next}, {"^Benchmark %s Time %s CPU %s Iterations UserCounters...$", MR_Next}, {"^[-]+$", MR_Next}})
void BM_Invert(benchmark::State &state)
void CheckBytesAndItemsPSec(Results const &e)
void BM_Counters_IterationInvariant(benchmark::State &state)
void CheckAvgIterations(Results const &e)
void RunOutputTests(int argc, char *argv[])
#define CHECK_FLOAT_COUNTER_VALUE(entry, var_name, relationship, value, eps_factor)
void CheckAvgIterationsRate(Results const &e)
void CheckIterationInvariant(Results const &e)
void CheckSimple(Results const &e)
int main(int argc, char *argv[])
void BM_Counters_Threads(benchmark::State &state)
void BM_Counters_Rate(benchmark::State &state)
#define CHECK_COUNTER_VALUE(entry, var_type, var_name, relationship, value)
void BM_Counters_Simple(benchmark::State &state)
void BM_Counters_WithBytesAndItemsPSec(benchmark::State &state)
void BM_Counters_AvgThreads(benchmark::State &state)
void CheckRate(Results const &e)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:48