fixture_test.cc
Go to the documentation of this file.
1 
2 #include "benchmark/benchmark.h"
3 
4 #include <cassert>
5 #include <memory>
6 
8  public:
9  void SetUp(const ::benchmark::State& state) {
10  if (state.thread_index == 0) {
11  assert(data.get() == nullptr);
12  data.reset(new int(42));
13  }
14  }
15 
16  void TearDown(const ::benchmark::State& state) {
17  if (state.thread_index == 0) {
18  assert(data.get() != nullptr);
19  data.reset();
20  }
21  }
22 
23  ~MyFixture() { assert(data == nullptr); }
24 
25  std::unique_ptr<int> data;
26 };
27 
29  assert(data.get() != nullptr);
30  assert(*data == 42);
31  while (st.KeepRunning()) {
32  }
33 }
34 
36  if (st.thread_index == 0) {
37  assert(data.get() != nullptr);
38  assert(*data == 42);
39  }
40  while (st.KeepRunning()) {
41  assert(data.get() != nullptr);
42  assert(*data == 42);
43  }
44  st.SetItemsProcessed(st.range(0));
45 }
46 BENCHMARK_REGISTER_F(MyFixture, Bar)->Arg(42);
47 BENCHMARK_REGISTER_F(MyFixture, Bar)->Arg(42)->ThreadPerCpu();
48 
MyFixture::~MyFixture
~MyFixture()
Definition: fixture_test.cc:23
MyFixture::data
std::unique_ptr< int > data
Definition: fixture_test.cc:25
BENCHMARK_REGISTER_F
BENCHMARK_REGISTER_F(MyFixture, Bar) -> Arg(42)
MyFixture
Definition: fixture_test.cc:7
benchmark::Fixture
Definition: benchmark.h:850
BENCHMARK_DEFINE_F
BENCHMARK_DEFINE_F(MyFixture, Bar)(benchmark
Definition: fixture_test.cc:35
BENCHMARK_MAIN
#define BENCHMARK_MAIN()
Definition: benchmark.h:988
MyFixture::SetUp
void SetUp(const ::benchmark::State &state)
Definition: fixture_test.cc:9
benchmark::State
Definition: benchmark.h:399
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
BENCHMARK_F
BENCHMARK_F(MyFixture, Foo)(benchmark
Definition: fixture_test.cc:28
MyFixture::TearDown
void TearDown(const ::benchmark::State &state)
Definition: fixture_test.cc:16
benchmark.h


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51