user_counters_thousands_test.cc
Go to the documentation of this file.
1 
2 #undef NDEBUG
3 
4 #include "benchmark/benchmark.h"
5 #include "output_test.h"
6 
7 // ========================================================================= //
8 // ------------------------ Thousands Customisation ------------------------ //
9 // ========================================================================= //
10 
12  for (auto _ : state) {
13  }
14  namespace bm = benchmark;
15  state.counters.insert({
16  {"t0_1000000DefaultBase",
17  bm::Counter(1000 * 1000, bm::Counter::kDefaults)},
18  {"t1_1000000Base1000", bm::Counter(1000 * 1000, bm::Counter::kDefaults,
19  benchmark::Counter::OneK::kIs1000)},
20  {"t2_1000000Base1024", bm::Counter(1000 * 1000, bm::Counter::kDefaults,
21  benchmark::Counter::OneK::kIs1024)},
22  {"t3_1048576Base1000", bm::Counter(1024 * 1024, bm::Counter::kDefaults,
23  benchmark::Counter::OneK::kIs1000)},
24  {"t4_1048576Base1024", bm::Counter(1024 * 1024, bm::Counter::kDefaults,
25  benchmark::Counter::OneK::kIs1024)},
26  });
27 }
28 BENCHMARK(BM_Counters_Thousands)->Repetitions(2);
29 ADD_CASES(
31  {
32  {"^BM_Counters_Thousands/repeats:2 %console_report "
33  "t0_1000000DefaultBase=1000k "
34  "t1_1000000Base1000=1000k t2_1000000Base1024=976.56[23]k "
35  "t3_1048576Base1000=1048.58k t4_1048576Base1024=1024k$"},
36  {"^BM_Counters_Thousands/repeats:2 %console_report "
37  "t0_1000000DefaultBase=1000k "
38  "t1_1000000Base1000=1000k t2_1000000Base1024=976.56[23]k "
39  "t3_1048576Base1000=1048.58k t4_1048576Base1024=1024k$"},
40  {"^BM_Counters_Thousands/repeats:2_mean %console_report "
41  "t0_1000000DefaultBase=1000k t1_1000000Base1000=1000k "
42  "t2_1000000Base1024=976.56[23]k t3_1048576Base1000=1048.58k "
43  "t4_1048576Base1024=1024k$"},
44  {"^BM_Counters_Thousands/repeats:2_median %console_report "
45  "t0_1000000DefaultBase=1000k t1_1000000Base1000=1000k "
46  "t2_1000000Base1024=976.56[23]k t3_1048576Base1000=1048.58k "
47  "t4_1048576Base1024=1024k$"},
48  {"^BM_Counters_Thousands/repeats:2_stddev %console_time_only_report [ "
49  "]*2 t0_1000000DefaultBase=0 t1_1000000Base1000=0 "
50  "t2_1000000Base1024=0 t3_1048576Base1000=0 t4_1048576Base1024=0$"},
51  });
53  {{"\"name\": \"BM_Counters_Thousands/repeats:2\",$"},
54  {"\"family_index\": 0,$", MR_Next},
55  {"\"per_family_instance_index\": 0,$", MR_Next},
56  {"\"run_name\": \"BM_Counters_Thousands/repeats:2\",$", MR_Next},
57  {"\"run_type\": \"iteration\",$", MR_Next},
58  {"\"repetitions\": 2,$", MR_Next},
59  {"\"repetition_index\": 0,$", MR_Next},
60  {"\"threads\": 1,$", MR_Next},
61  {"\"iterations\": %int,$", MR_Next},
62  {"\"real_time\": %float,$", MR_Next},
63  {"\"cpu_time\": %float,$", MR_Next},
64  {"\"time_unit\": \"ns\",$", MR_Next},
65  {"\"t0_1000000DefaultBase\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
66  {"\"t1_1000000Base1000\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
67  {"\"t2_1000000Base1024\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
68  {"\"t3_1048576Base1000\": 1\\.048576(0)*e\\+(0)*6,$", MR_Next},
69  {"\"t4_1048576Base1024\": 1\\.048576(0)*e\\+(0)*6$", MR_Next},
70  {"}", MR_Next}});
72  {{"\"name\": \"BM_Counters_Thousands/repeats:2\",$"},
73  {"\"family_index\": 0,$", MR_Next},
74  {"\"per_family_instance_index\": 0,$", MR_Next},
75  {"\"run_name\": \"BM_Counters_Thousands/repeats:2\",$", MR_Next},
76  {"\"run_type\": \"iteration\",$", MR_Next},
77  {"\"repetitions\": 2,$", MR_Next},
78  {"\"repetition_index\": 1,$", MR_Next},
79  {"\"threads\": 1,$", MR_Next},
80  {"\"iterations\": %int,$", MR_Next},
81  {"\"real_time\": %float,$", MR_Next},
82  {"\"cpu_time\": %float,$", MR_Next},
83  {"\"time_unit\": \"ns\",$", MR_Next},
84  {"\"t0_1000000DefaultBase\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
85  {"\"t1_1000000Base1000\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
86  {"\"t2_1000000Base1024\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
87  {"\"t3_1048576Base1000\": 1\\.048576(0)*e\\+(0)*6,$", MR_Next},
88  {"\"t4_1048576Base1024\": 1\\.048576(0)*e\\+(0)*6$", MR_Next},
89  {"}", MR_Next}});
91  {{"\"name\": \"BM_Counters_Thousands/repeats:2_mean\",$"},
92  {"\"family_index\": 0,$", MR_Next},
93  {"\"per_family_instance_index\": 0,$", MR_Next},
94  {"\"run_name\": \"BM_Counters_Thousands/repeats:2\",$", MR_Next},
95  {"\"run_type\": \"aggregate\",$", MR_Next},
96  {"\"repetitions\": 2,$", MR_Next},
97  {"\"threads\": 1,$", MR_Next},
98  {"\"aggregate_name\": \"mean\",$", MR_Next},
99  {"\"aggregate_unit\": \"time\",$", MR_Next},
100  {"\"iterations\": 2,$", MR_Next},
101  {"\"real_time\": %float,$", MR_Next},
102  {"\"cpu_time\": %float,$", MR_Next},
103  {"\"time_unit\": \"ns\",$", MR_Next},
104  {"\"t0_1000000DefaultBase\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
105  {"\"t1_1000000Base1000\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
106  {"\"t2_1000000Base1024\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
107  {"\"t3_1048576Base1000\": 1\\.048576(0)*e\\+(0)*6,$", MR_Next},
108  {"\"t4_1048576Base1024\": 1\\.048576(0)*e\\+(0)*6$", MR_Next},
109  {"}", MR_Next}});
111  {{"\"name\": \"BM_Counters_Thousands/repeats:2_median\",$"},
112  {"\"family_index\": 0,$", MR_Next},
113  {"\"per_family_instance_index\": 0,$", MR_Next},
114  {"\"run_name\": \"BM_Counters_Thousands/repeats:2\",$", MR_Next},
115  {"\"run_type\": \"aggregate\",$", MR_Next},
116  {"\"repetitions\": 2,$", MR_Next},
117  {"\"threads\": 1,$", MR_Next},
118  {"\"aggregate_name\": \"median\",$", MR_Next},
119  {"\"aggregate_unit\": \"time\",$", MR_Next},
120  {"\"iterations\": 2,$", MR_Next},
121  {"\"real_time\": %float,$", MR_Next},
122  {"\"cpu_time\": %float,$", MR_Next},
123  {"\"time_unit\": \"ns\",$", MR_Next},
124  {"\"t0_1000000DefaultBase\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
125  {"\"t1_1000000Base1000\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
126  {"\"t2_1000000Base1024\": 1\\.(0)*e\\+(0)*6,$", MR_Next},
127  {"\"t3_1048576Base1000\": 1\\.048576(0)*e\\+(0)*6,$", MR_Next},
128  {"\"t4_1048576Base1024\": 1\\.048576(0)*e\\+(0)*6$", MR_Next},
129  {"}", MR_Next}});
131  {{"\"name\": \"BM_Counters_Thousands/repeats:2_stddev\",$"},
132  {"\"family_index\": 0,$", MR_Next},
133  {"\"per_family_instance_index\": 0,$", MR_Next},
134  {"\"run_name\": \"BM_Counters_Thousands/repeats:2\",$", MR_Next},
135  {"\"run_type\": \"aggregate\",$", MR_Next},
136  {"\"repetitions\": 2,$", MR_Next},
137  {"\"threads\": 1,$", MR_Next},
138  {"\"aggregate_name\": \"stddev\",$", MR_Next},
139  {"\"aggregate_unit\": \"time\",$", MR_Next},
140  {"\"iterations\": 2,$", MR_Next},
141  {"\"real_time\": %float,$", MR_Next},
142  {"\"cpu_time\": %float,$", MR_Next},
143  {"\"time_unit\": \"ns\",$", MR_Next},
144  {"\"t0_1000000DefaultBase\": 0\\.(0)*e\\+(0)*,$", MR_Next},
145  {"\"t1_1000000Base1000\": 0\\.(0)*e\\+(0)*,$", MR_Next},
146  {"\"t2_1000000Base1024\": 0\\.(0)*e\\+(0)*,$", MR_Next},
147  {"\"t3_1048576Base1000\": 0\\.(0)*e\\+(0)*,$", MR_Next},
148  {"\"t4_1048576Base1024\": 0\\.(0)*e\\+(0)*$", MR_Next},
149  {"}", MR_Next}});
150 
151 ADD_CASES(
152  TC_CSVOut,
153  {{"^\"BM_Counters_Thousands/"
154  "repeats:2\",%csv_report,1e\\+(0)*6,1e\\+(0)*6,1e\\+(0)*6,1\\.04858e\\+("
155  "0)*6,1\\.04858e\\+(0)*6$"},
156  {"^\"BM_Counters_Thousands/"
157  "repeats:2\",%csv_report,1e\\+(0)*6,1e\\+(0)*6,1e\\+(0)*6,1\\.04858e\\+("
158  "0)*6,1\\.04858e\\+(0)*6$"},
159  {"^\"BM_Counters_Thousands/"
160  "repeats:2_mean\",%csv_report,1e\\+(0)*6,1e\\+(0)*6,1e\\+(0)*6,1\\."
161  "04858e\\+(0)*6,1\\.04858e\\+(0)*6$"},
162  {"^\"BM_Counters_Thousands/"
163  "repeats:2_median\",%csv_report,1e\\+(0)*6,1e\\+(0)*6,1e\\+(0)*6,1\\."
164  "04858e\\+(0)*6,1\\.04858e\\+(0)*6$"},
165  {"^\"BM_Counters_Thousands/repeats:2_stddev\",%csv_report,0,0,0,0,0$"}});
166 // VS2013 does not allow this function to be passed as a lambda argument
167 // to CHECK_BENCHMARK_RESULTS()
168 void CheckThousands(Results const& e) {
169  if (e.name != "BM_Counters_Thousands/repeats:2")
170  return; // Do not check the aggregates!
171 
172  // check that the values are within 0.01% of the expected values
173  CHECK_FLOAT_COUNTER_VALUE(e, "t0_1000000DefaultBase", EQ, 1000 * 1000,
174  0.0001);
175  CHECK_FLOAT_COUNTER_VALUE(e, "t1_1000000Base1000", EQ, 1000 * 1000, 0.0001);
176  CHECK_FLOAT_COUNTER_VALUE(e, "t2_1000000Base1024", EQ, 1000 * 1000, 0.0001);
177  CHECK_FLOAT_COUNTER_VALUE(e, "t3_1048576Base1000", EQ, 1024 * 1024, 0.0001);
178  CHECK_FLOAT_COUNTER_VALUE(e, "t4_1048576Base1024", EQ, 1024 * 1024, 0.0001);
179 }
180 CHECK_BENCHMARK_RESULTS("BM_Counters_Thousands", &CheckThousands);
181 
182 // ========================================================================= //
183 // --------------------------- TEST CASES END ------------------------------ //
184 // ========================================================================= //
185 
186 int main(int argc, char* argv[]) { RunOutputTests(argc, argv); }
benchmark
Definition: bm_alarm.cc:55
CHECK_BENCHMARK_RESULTS
CHECK_BENCHMARK_RESULTS("BM_Counters_Thousands", &CheckThousands)
MR_Next
@ MR_Next
Definition: benchmark/test/output_test.h:26
EQ
#define EQ(a, b)
Definition: aix.c:66
TC_CSVOut
@ TC_CSVOut
Definition: benchmark/test/output_test.h:45
TC_JSONOut
@ TC_JSONOut
Definition: benchmark/test/output_test.h:43
output_test.h
BM_Counters_Thousands
void BM_Counters_Thousands(benchmark::State &state)
Definition: user_counters_thousands_test.cc:11
main
int main(int argc, char *argv[])
Definition: user_counters_thousands_test.cc:186
Results
Definition: benchmark/test/output_test.h:92
gmock_output_test._
_
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
BENCHMARK
BENCHMARK(BM_Counters_Thousands) -> Repetitions(2)
TC_ConsoleOut
@ TC_ConsoleOut
Definition: benchmark/test/output_test.h:41
RunOutputTests
void RunOutputTests(int argc, char *argv[])
Definition: benchmark/test/output_test_helper.cc:391
CHECK_FLOAT_COUNTER_VALUE
#define CHECK_FLOAT_COUNTER_VALUE(entry, var_name, relationship, value, eps_factor)
Definition: benchmark/test/output_test.h:198
CheckThousands
void CheckThousands(Results const &e)
Definition: user_counters_thousands_test.cc:168
benchmark::State
Definition: benchmark/include/benchmark/benchmark.h:503
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
ADD_CASES
ADD_CASES(TC_ConsoleOut, { {"^BM_Counters_Thousands/repeats:2 %console_report " "t0_1000000DefaultBase=1000k " "t1_1000000Base1000=1000k t2_1000000Base1024=976.56[23]k " "t3_1048576Base1000=1048.58k t4_1048576Base1024=1024k$"}, {"^BM_Counters_Thousands/repeats:2 %console_report " "t0_1000000DefaultBase=1000k " "t1_1000000Base1000=1000k t2_1000000Base1024=976.56[23]k " "t3_1048576Base1000=1048.58k t4_1048576Base1024=1024k$"}, {"^BM_Counters_Thousands/repeats:2_mean %console_report " "t0_1000000DefaultBase=1000k t1_1000000Base1000=1000k " "t2_1000000Base1024=976.56[23]k t3_1048576Base1000=1048.58k " "t4_1048576Base1024=1024k$"}, {"^BM_Counters_Thousands/repeats:2_median %console_report " "t0_1000000DefaultBase=1000k t1_1000000Base1000=1000k " "t2_1000000Base1024=976.56[23]k t3_1048576Base1000=1048.58k " "t4_1048576Base1024=1024k$"}, {"^BM_Counters_Thousands/repeats:2_stddev %console_time_only_report [ " "]*2 t0_1000000DefaultBase=0 t1_1000000Base1000=0 " "t2_1000000Base1024=0 t3_1048576Base1000=0 t4_1048576Base1024=0$"}, })


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:48