diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:21:10 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-20 21:21:10 +0000 |
| commit | 1c3313bd0215c89fb38710a1ea0762ccf32e859c (patch) | |
| tree | 65e6d33ca6254b41a8f4230edff47c5344dbd019 /utils/google-benchmark/test/benchmark_test.cc | |
| parent | 0dc0969cd0a732760f0aa79942a04e0eaef297c4 (diff) | |
Notes
Diffstat (limited to 'utils/google-benchmark/test/benchmark_test.cc')
| -rw-r--r-- | utils/google-benchmark/test/benchmark_test.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/utils/google-benchmark/test/benchmark_test.cc b/utils/google-benchmark/test/benchmark_test.cc index d832f81ae433..57731331e6d0 100644 --- a/utils/google-benchmark/test/benchmark_test.cc +++ b/utils/google-benchmark/test/benchmark_test.cc @@ -150,7 +150,7 @@ static void BM_LongTest(benchmark::State& state) { BENCHMARK(BM_LongTest)->Range(1 << 16, 1 << 28); static void BM_ParallelMemset(benchmark::State& state) { - int size = state.range(0) / sizeof(int); + int size = state.range(0) / static_cast<int>(sizeof(int)); int thread_size = size / state.threads; int from = thread_size * state.thread_index; int to = from + thread_size; @@ -209,10 +209,26 @@ BENCHMARK_CAPTURE(BM_with_args, string_and_pair_test, std::string("abc"), std::pair<int, double>(42, 3.8)); void BM_non_template_args(benchmark::State& state, int, double) { + while(state.KeepRunning()) {} +} +BENCHMARK_CAPTURE(BM_non_template_args, basic_test, 0, 0); + +static void BM_UserCounter(benchmark::State& state) { + static const int depth = 1024; while (state.KeepRunning()) { + benchmark::DoNotOptimize(CalculatePi(depth)); } + state.counters["Foo"] = 1; + state.counters["Bar"] = 2; + state.counters["Baz"] = 3; + state.counters["Bat"] = 5; +#ifdef BENCHMARK_HAS_CXX11 + state.counters.insert({{"Foo", 2}, {"Bar", 3}, {"Baz", 5}, {"Bat", 6}}); +#endif } -BENCHMARK_CAPTURE(BM_non_template_args, basic_test, 0, 0); +BENCHMARK(BM_UserCounter)->Threads(8); +BENCHMARK(BM_UserCounter)->ThreadRange(1, 32); +BENCHMARK(BM_UserCounter)->ThreadPerCpu(); #endif // __cplusplus >= 201103L |
