| 76 | } |
| 77 | |
| 78 | static void BitmapWordReaderBench(benchmark::State& state) { |
| 79 | int64_t nbytes = state.range(0); |
| 80 | std::shared_ptr<Buffer> cond_buf = CreateRandomBuffer(nbytes); |
| 81 | for (auto _ : state) { |
| 82 | BitmapWordReader<uint64_t> counter(cond_buf->data(), 0, nbytes * 8); |
| 83 | |
| 84 | int64_t set_bits = 0; |
| 85 | |
| 86 | int64_t cnt = counter.words(); |
| 87 | while (cnt--) { |
| 88 | const auto& word = counter.NextWord(); |
| 89 | // if (word == UINT64_MAX) { |
| 90 | // set_bits += sizeof(uint64_t) * 8; |
| 91 | // } else if (word) { |
| 92 | // set_bits += std::popcount(word); |
| 93 | // } |
| 94 | set_bits += std::popcount(word); |
| 95 | benchmark::DoNotOptimize(set_bits); |
| 96 | } |
| 97 | |
| 98 | cnt = counter.trailing_bytes(); |
| 99 | while (cnt--) { |
| 100 | int valid_bits; |
| 101 | const auto& byte = static_cast<uint32_t>(counter.NextTrailingByte(valid_bits)); |
| 102 | set_bits += std::popcount(kPrecedingBitmask[valid_bits] & byte); |
| 103 | benchmark::DoNotOptimize(set_bits); |
| 104 | } |
| 105 | benchmark::ClobberMemory(); |
| 106 | } |
| 107 | state.SetBytesProcessed(state.iterations() * nbytes); |
| 108 | } |
| 109 | |
| 110 | BENCHMARK(BitBlockCounterBench)->Arg(kBufferSize); |
| 111 | BENCHMARK(BitmapWordReaderBench)->Arg(kBufferSize); |
nothing calls this directly
no test coverage detected