@@ -127,43 +127,9 @@ BENCHMARK(BM_WithRep)
127127 ->Iterations(100 )
128128 ->Repetitions(4 );
129129
130- namespace withfunctors {
131- static int setup_call = 0 ;
132- static int teardown_call = 0 ;
133- }
134- namespace withlambdas {
135- static int setup_call = 0 ;
136- static int teardown_call = 0 ;
137- }
138- struct Functor {
139- int & var;
140- Functor (int & v) : var(v) {}
141- void operator ()(const benchmark::State& /* unused*/ ) { var++; }
142- };
143-
144130int main (int argc, char ** argv) {
145131 benchmark::Initialize (&argc, argv);
146132
147- auto bmf = benchmark::RegisterBenchmark (" BM_with_functors" ,
148- [](benchmark::State& state) {
149- for (auto _ : state) {
150- }
151- });
152- bmf->Arg (1 )->Arg (2 )->Iterations (10 );
153- bmf->Setup (Functor (withfunctors::setup_call));
154- bmf->Teardown (Functor (withfunctors::teardown_call));
155-
156- auto bml = benchmark::RegisterBenchmark (" BM_with_lambdas" ,
157- [](benchmark::State& state) {
158- for (auto _ : state) {
159- }
160- });
161- bml->Arg (1 )->Arg (2 )->Iterations (10 );
162- bml->Setup (
163- [](const benchmark::State& /* unused*/ ) { withlambdas::setup_call++; });
164- bml->Teardown (
165- [](const benchmark::State& /* unused*/ ) { withlambdas::teardown_call++; });
166-
167133 size_t ret = benchmark::RunSpecifiedBenchmarks (" ." );
168134 assert (ret > 0 );
169135
@@ -187,13 +153,5 @@ int main(int argc, char** argv) {
187153 // Setup is call once for each repetition * num_arg = 4 * 4 = 16.
188154 assert (repetitions::setup == 16 );
189155
190- // Setup/Teardown is called once for each arg group (1,2).
191- assert (withlambdas::setup_call == 2 );
192- assert (withlambdas::teardown_call == 2 );
193-
194- // Setup/Teardown is called once for each arg group (1,2).
195- assert (withlambdas::setup_call == 2 );
196- assert (withlambdas::teardown_call == 2 );
197-
198156 return 0 ;
199157}
0 commit comments