Eric Fiselier | 4d5e91d | 2016-08-29 19:12:01 +0000 | [diff] [blame^] | 1 | #undef NDEBUG |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 2 | #include <cstddef> |
Eric Fiselier | 4d5e91d | 2016-08-29 19:12:01 +0000 | [diff] [blame^] | 3 | #include <cassert> |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 4 | |
| 5 | #include "benchmark/benchmark.h" |
| 6 | |
| 7 | #if __cplusplus >= 201103L |
| 8 | #error C++11 or greater detected. Should be C++03. |
| 9 | #endif |
| 10 | |
| 11 | void BM_empty(benchmark::State& state) { |
| 12 | while (state.KeepRunning()) { |
| 13 | volatile std::size_t x = state.iterations(); |
| 14 | ((void)x); |
| 15 | } |
| 16 | } |
| 17 | BENCHMARK(BM_empty); |
| 18 | |
Eric Fiselier | 4d5e91d | 2016-08-29 19:12:01 +0000 | [diff] [blame^] | 19 | // The new C++11 interface for args/ranges requires initializer list support. |
| 20 | // Therefore we provide the old interface to support C++03. |
| 21 | void BM_old_arg_range_interface(benchmark::State& state) { |
| 22 | assert((state.range(0) == 1 && state.range(1) == 2) || |
| 23 | (state.range(0) == 5 && state.range(1) == 6)); |
| 24 | while (state.KeepRunning()) { |
| 25 | } |
| 26 | } |
| 27 | BENCHMARK(BM_old_arg_range_interface)->ArgPair(1, 2)->RangePair(5, 5, 6, 6); |
| 28 | |
Eric Fiselier | b08d8b1 | 2016-07-19 23:07:03 +0000 | [diff] [blame] | 29 | template <class T, class U> |
| 30 | void BM_template2(benchmark::State& state) { |
| 31 | BM_empty(state); |
| 32 | } |
| 33 | BENCHMARK_TEMPLATE2(BM_template2, int, long); |
| 34 | |
| 35 | template <class T> |
| 36 | void BM_template1(benchmark::State& state) { |
| 37 | BM_empty(state); |
| 38 | } |
| 39 | BENCHMARK_TEMPLATE(BM_template1, long); |
| 40 | BENCHMARK_TEMPLATE1(BM_template1, int); |
| 41 | |
| 42 | BENCHMARK_MAIN() |