-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfixture_bench.hpp
More file actions
68 lines (55 loc) · 1.51 KB
/
fixture_bench.hpp
File metadata and controls
68 lines (55 loc) · 1.51 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// See docs:
// https://github.com/google/benchmark/blob/main/docs/user_guide.md#fixtures
#ifndef FIXTURE_BENCH_HPP
#define FIXTURE_BENCH_HPP
#include <benchmark/benchmark.h>
namespace example_namespace {
class MyFixture : public benchmark::Fixture {
public:
void SetUp(::benchmark::State &state) { (void)state; }
void TearDown(::benchmark::State &state) { (void)state; }
};
BENCHMARK_F(MyFixture, FooTest)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_DEFINE_F(MyFixture, BarTest)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_REGISTER_F(MyFixture, BarTest);
//
//
template <typename T>
class MyTemplatedFixture : public benchmark::Fixture {};
BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_TEMPLATE_DEFINE_F(MyTemplatedFixture, DoubleTest,
double)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_REGISTER_F(MyTemplatedFixture, DoubleTest);
//
//
template <typename T>
class MyTemplate1 : public benchmark::Fixture {};
BENCHMARK_TEMPLATE1_DEFINE_F(MyTemplate1, TestA, int)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_REGISTER_F(MyTemplate1, TestA);
//
//
template <typename T, typename U>
class MyTemplate2 : public benchmark::Fixture {};
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int,
double)(benchmark::State &st) {
for (auto _ : st) {
}
}
BENCHMARK_REGISTER_F(MyTemplate2, TestB);
} // namespace example_namespace
#endif