Skip to content

Commit

Permalink
Handling combinatorial explosion in BENCHMARK_...
Browse files Browse the repository at this point in the history
  • Loading branch information
hivert committed Nov 1, 2023
1 parent e9c12e8 commit 2d04dc4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions benchmark/bench_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,34 @@
return true; \
};

#define BENCHMARK_MEM_FN_PAIR_EQ(mem_fn, sample) \
#define BENCHMARK_MEM_FN_PAIR(mem_fn, sample) \
BENCHMARK(#mem_fn) { \
for (auto &pair : sample) { \
volatile auto val = pair.first.mem_fn(pair.second); \
} \
return true; \
};

#define BENCHMARK_FREE_FN_PAIR(free_fn, sample) \
BENCHMARK(#free_fn) { \
for (auto &pair : sample) { \
volatile auto val = free_fn(pair.first, pair.second); \
} \
return true; \
};

#define BENCHMARK_FREE_FN_PAIR_EQ(mem_fn, sample) \
BENCHMARK(#mem_fn) { \
for (auto &pair : sample) { \
auto val = \
std::make_pair(pair.first.mem_fn(), pair.second.mem_fn()); \
REQUIRE(val.first == val.second); \
REQUIRE(free_fn(pair.first) == free_fn(pair.second)); \
} \
return true; \
};

#define BENCHMARK_FREE_FN_PAIR(free_fn, sample) \
BENCHMARK(#free_fn) { \
#define BENCHMARK_MEM_FN_PAIR_EQ(mem_fn, sample) \
BENCHMARK(#mem_fn) { \
for (auto &pair : sample) { \
volatile auto val = free_fn(pair.first, pair.second); \
REQUIRE(pair.first.mem_fn() == pair.second.mem_fn()); \
} \
return true; \
};

0 comments on commit 2d04dc4

Please sign in to comment.