protobuf/third_party/benchmark/test/fixture_test.cc
Go to the documentation of this file.
1 
2 #include "benchmark/benchmark.h"
3 
4 #include <cassert>
5 #include <memory>
6 
7 class MyFixture : public ::benchmark::Fixture {
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: protobuf/third_party/benchmark/test/fixture_test.cc:23
BENCHMARK_F
BENCHMARK_F(MyFixture, Foo)(benchmark
Definition: protobuf/third_party/benchmark/test/fixture_test.cc:28
MyFixture::data
T data
Definition: templated_fixture_test.cc:12
BENCHMARK_REGISTER_F
BENCHMARK_REGISTER_F(MyFixture, Bar) -> Arg(42)
MyFixture
Definition: templated_fixture_test.cc:8
benchmark::Fixture
Definition: benchmark/include/benchmark/benchmark.h:1122
Foo
Definition: abseil-cpp/absl/debugging/symbolize_test.cc:65
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
BENCHMARK_DEFINE_F
BENCHMARK_DEFINE_F(MyFixture, Bar)(benchmark
Definition: protobuf/third_party/benchmark/test/fixture_test.cc:35
benchmark::State
Definition: benchmark/include/benchmark/benchmark.h:503
BENCHMARK_MAIN
#define BENCHMARK_MAIN()
Definition: benchmark/include/benchmark/benchmark.h:1338
state
Definition: bloaty/third_party/zlib/contrib/blast/blast.c:41
MyFixture::TearDown
void TearDown(const ::benchmark::State &state)
Definition: protobuf/third_party/benchmark/test/fixture_test.cc:16
MyFixture::SetUp
void SetUp(const ::benchmark::State &state)
Definition: protobuf/third_party/benchmark/test/fixture_test.cc:9


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:24