MCPcopy Create free account
hub / github.com/apache/arrow / BitmapWordReaderBench

Function BitmapWordReaderBench

cpp/src/arrow/util/bitmap_reader_benchmark.cc:78–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78static 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
110BENCHMARK(BitBlockCounterBench)->Arg(kBufferSize);
111BENCHMARK(BitmapWordReaderBench)->Arg(kBufferSize);

Callers

nothing calls this directly

Calls 6

trailing_bytesMethod · 0.80
NextTrailingByteMethod · 0.80
CreateRandomBufferFunction · 0.70
dataMethod · 0.45
wordsMethod · 0.45
NextWordMethod · 0.45

Tested by

no test coverage detected