diff options
Diffstat (limited to 'test/templated_fixture_test.cc')
-rw-r--r-- | test/templated_fixture_test.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/templated_fixture_test.cc b/test/templated_fixture_test.cc new file mode 100644 index 0000000..ec5b4c0 --- /dev/null +++ b/test/templated_fixture_test.cc @@ -0,0 +1,28 @@ + +#include "benchmark/benchmark.h" + +#include <cassert> +#include <memory> + +template<typename T> +class MyFixture : public ::benchmark::Fixture { +public: + MyFixture() : data(0) {} + + T data; +}; + +BENCHMARK_TEMPLATE_F(MyFixture, Foo, int)(benchmark::State &st) { + for (auto _ : st) { + data += 1; + } +} + +BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) { + for (auto _ : st) { + data += 1.0; + } +} +BENCHMARK_REGISTER_F(MyFixture, Bar); + +BENCHMARK_MAIN(); |