Benchmarks ReadRecords and SkipRecords for RecordReader with the following parameters in order: - repetition: 0 for REQUIRED, 1 for OPTIONAL, 2 for REPEATED. - batch_size: sets how many values to read/skip at each call. - levels_per_page: sets how many levels to read/skip in total.
| 204 | // - batch_size: sets how many values to read/skip at each call. |
| 205 | // - levels_per_page: sets how many levels to read/skip in total. |
| 206 | static void RecordReaderReadAndSkipRecords(::benchmark::State& state) { |
| 207 | const auto repetition = static_cast<Repetition::type>(state.range(0)); |
| 208 | const auto batch_size = static_cast<int64_t>(state.range(1)); |
| 209 | const auto levels_per_page = static_cast<int>(state.range(2)); |
| 210 | |
| 211 | BenchmarkHelper helper(repetition, /*num_pages=*/16, levels_per_page); |
| 212 | |
| 213 | // Vectors to read the values into. |
| 214 | for (auto _ : state) { |
| 215 | state.PauseTiming(); |
| 216 | // read_dense_for_nullable should not matter for skip. |
| 217 | RecordReader* reader = helper.ResetRecordReader(/*read_dense_for_nullable=*/false); |
| 218 | int64_t records_read = -1; |
| 219 | int64_t records_skipped = -1; |
| 220 | state.ResumeTiming(); |
| 221 | while (records_read != 0 && records_skipped != 0) { |
| 222 | // ReadRecords may buffer some levels which will be skipped by the following |
| 223 | // SkipRecords. |
| 224 | DoNotOptimize(records_read = reader->ReadRecords(batch_size)); |
| 225 | DoNotOptimize(records_skipped = reader->SkipRecords(batch_size)); |
| 226 | reader->Reset(); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | state.SetBytesProcessed(state.iterations() * helper.total_size()); |
| 231 | state.SetItemsProcessed(state.iterations() * helper.total_levels()); |
| 232 | } |
| 233 | |
| 234 | BENCHMARK(ColumnReaderSkipInt32) |
| 235 | ->ArgNames({"Repetition", "BatchSize"}) |
nothing calls this directly
no test coverage detected