| 288 | |
| 289 | template <typename BitmapWriterType> |
| 290 | static void BenchmarkBitmapWriter(benchmark::State& state, int64_t nbytes) { |
| 291 | std::shared_ptr<Buffer> buffer = CreateRandomBuffer(nbytes); |
| 292 | |
| 293 | const int64_t num_bits = nbytes * 8; |
| 294 | uint8_t* bitmap = buffer->mutable_data(); |
| 295 | |
| 296 | for (auto _ : state) { |
| 297 | BitmapWriterType writer(bitmap, 0, num_bits); |
| 298 | int64_t pattern_index = 0; |
| 299 | for (int64_t i = 0; i < num_bits; i++) { |
| 300 | if (pattern[pattern_index++]) { |
| 301 | writer.Set(); |
| 302 | } else { |
| 303 | writer.Clear(); |
| 304 | } |
| 305 | if (pattern_index == sizeof(pattern) / sizeof(bool)) { |
| 306 | pattern_index = 0; |
| 307 | } |
| 308 | writer.Next(); |
| 309 | } |
| 310 | writer.Finish(); |
| 311 | benchmark::ClobberMemory(); |
| 312 | } |
| 313 | state.SetBytesProcessed(state.iterations() * nbytes); |
| 314 | } |
| 315 | |
| 316 | template <typename GenerateBitsFunctorType> |
| 317 | static void BenchmarkGenerateBits(benchmark::State& state, int64_t nbytes) { |
nothing calls this directly
no test coverage detected