blob: 9994c9e1cf695d241bdaf45122e19b02a20d869c [file] [log] [blame]
Eric Fiselier4d5e91d2016-08-29 19:12:01 +00001#undef NDEBUG
Eric Fiselierb08d8b12016-07-19 23:07:03 +00002#include <cstddef>
Eric Fiselier4d5e91d2016-08-29 19:12:01 +00003#include <cassert>
Eric Fiselierb08d8b12016-07-19 23:07:03 +00004
5#include "benchmark/benchmark.h"
6
7#if __cplusplus >= 201103L
8#error C++11 or greater detected. Should be C++03.
9#endif
10
11void BM_empty(benchmark::State& state) {
12 while (state.KeepRunning()) {
13 volatile std::size_t x = state.iterations();
14 ((void)x);
15 }
16}
17BENCHMARK(BM_empty);
18
Eric Fiselier4d5e91d2016-08-29 19:12:01 +000019// The new C++11 interface for args/ranges requires initializer list support.
20// Therefore we provide the old interface to support C++03.
21void 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}
27BENCHMARK(BM_old_arg_range_interface)->ArgPair(1, 2)->RangePair(5, 5, 6, 6);
28
Eric Fiselierb08d8b12016-07-19 23:07:03 +000029template <class T, class U>
30void BM_template2(benchmark::State& state) {
31 BM_empty(state);
32}
33BENCHMARK_TEMPLATE2(BM_template2, int, long);
34
35template <class T>
36void BM_template1(benchmark::State& state) {
37 BM_empty(state);
38}
39BENCHMARK_TEMPLATE(BM_template1, long);
40BENCHMARK_TEMPLATE1(BM_template1, int);
41
42BENCHMARK_MAIN()