5 #include "benchmark/benchmark.h"
7 #define FIXTURE_BECHMARK_NAME MyFixture
9 class FIXTURE_BECHMARK_NAME
: public ::benchmark::Fixture
{
11 void SetUp(const ::benchmark::State
& state
) BENCHMARK_OVERRIDE
{
12 if (state
.thread_index() == 0) {
13 assert(data
.get() == nullptr);
14 data
.reset(new int(42));
18 void TearDown(const ::benchmark::State
& state
) BENCHMARK_OVERRIDE
{
19 if (state
.thread_index() == 0) {
20 assert(data
.get() != nullptr);
25 ~FIXTURE_BECHMARK_NAME() { assert(data
== nullptr); }
27 std::unique_ptr
<int> data
;
30 BENCHMARK_F(FIXTURE_BECHMARK_NAME
, Foo
)(benchmark::State
& st
) {
31 assert(data
.get() != nullptr);
37 BENCHMARK_DEFINE_F(FIXTURE_BECHMARK_NAME
, Bar
)(benchmark::State
& st
) {
38 if (st
.thread_index() == 0) {
39 assert(data
.get() != nullptr);
43 assert(data
.get() != nullptr);
46 st
.SetItemsProcessed(st
.range(0));
48 BENCHMARK_REGISTER_F(FIXTURE_BECHMARK_NAME
, Bar
)->Arg(42);
49 BENCHMARK_REGISTER_F(FIXTURE_BECHMARK_NAME
, Bar
)->Arg(42)->ThreadPerCpu();