| 259 | |
| 260 | template <typename VisitBitsFunctorType> |
| 261 | static void BenchmarkVisitBits(benchmark::State& state, int64_t nbytes) { |
| 262 | std::shared_ptr<Buffer> buffer = CreateRandomBuffer(nbytes); |
| 263 | |
| 264 | const int64_t num_bits = nbytes * 8; |
| 265 | const uint8_t* bitmap = buffer->data(); |
| 266 | |
| 267 | for (auto _ : state) { |
| 268 | { |
| 269 | int64_t total = 0; |
| 270 | const auto visit = [&total](bool value) -> void { total += value; }; |
| 271 | VisitBitsFunctorType()(bitmap, 0, num_bits, visit); |
| 272 | benchmark::DoNotOptimize(total); |
| 273 | } |
| 274 | { |
| 275 | int64_t total = 0; |
| 276 | const auto visit = [&total](bool value) -> void { total += value; }; |
| 277 | VisitBitsFunctorType()(bitmap, 0, num_bits, visit); |
| 278 | benchmark::DoNotOptimize(total); |
| 279 | } |
| 280 | } |
| 281 | state.SetBytesProcessed(2LL * state.iterations() * nbytes); |
| 282 | } |
| 283 | |
| 284 | constexpr bool pattern[] = {false, false, false, true, true, true}; |
| 285 | static_assert( |
nothing calls this directly
no test coverage detected