aboutsummaryrefslogtreecommitdiff
path: root/test/templated_fixture_test.cc
blob: ec5b4c0cc07821937a514745adf9d99514b204c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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();