File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -304,6 +304,10 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
304304
305305namespace benchmark {
306306class BenchmarkReporter ;
307+ class State ;
308+
309+ // Define alias of Setup/Teardown callback function type
310+ using callback_function = std::function<void (const benchmark::State&)>;
307311
308312// Default number of minimum benchmark running time in seconds.
309313const char kDefaultMinTimeStr [] = " 0.5s" ;
@@ -1080,9 +1084,6 @@ class BENCHMARK_EXPORT Benchmark {
10801084 public:
10811085 virtual ~Benchmark ();
10821086
1083- // Define alias of Setup/Teardown callback function type
1084- using callback_function = std::function<void (const benchmark::State&)>;
1085-
10861087 // Note: the following methods all return "this" so that multiple
10871088 // method calls can be chained together in one expression.
10881089
@@ -1164,7 +1165,9 @@ class BENCHMARK_EXPORT Benchmark {
11641165 //
11651166 // The callback must not be NULL or self-deleting.
11661167 Benchmark* Setup (callback_function&&);
1168+ Benchmark* Setup (const callback_function&);
11671169 Benchmark* Teardown (callback_function&&);
1170+ Benchmark* Teardown (const callback_function&);
11681171
11691172 // Pass this benchmark object to *func, which can customize
11701173 // the benchmark by calling various methods like Arg, Args,
Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ class BenchmarkInstance {
6868 IterationCount iterations_;
6969 int threads_; // Number of concurrent threads to us
7070
71- using callback_function = Benchmark::callback_function;
7271 callback_function setup_ = nullptr ;
7372 callback_function teardown_ = nullptr ;
7473};
Original file line number Diff line number Diff line change @@ -343,12 +343,24 @@ Benchmark* Benchmark::Setup(callback_function&& setup) {
343343 return this ;
344344}
345345
346+ Benchmark* Benchmark::Setup (const callback_function& setup) {
347+ BM_CHECK (setup != nullptr );
348+ setup_ = std::move (setup);
349+ return this ;
350+ }
351+
346352Benchmark* Benchmark::Teardown (callback_function&& teardown) {
347353 BM_CHECK (teardown != nullptr );
348354 teardown_ = std::forward<callback_function>(teardown);
349355 return this ;
350356}
351357
358+ Benchmark* Benchmark::Teardown (const callback_function& teardown) {
359+ BM_CHECK (teardown != nullptr );
360+ teardown_ = teardown;
361+ return this ;
362+ }
363+
352364Benchmark* Benchmark::RangeMultiplier (int multiplier) {
353365 BM_CHECK (multiplier > 1 );
354366 range_multiplier_ = multiplier;
You can’t perform that action at this time.
0 commit comments