From d7f290a9de98f91b2bc9477e7be9bf53f0f02b99 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Tue, 23 Jan 2024 17:48:06 +0100 Subject: [PATCH] GH-39666: [C++] Ensure CSV and JSON benchmarks present a bytes/s or items/s metric --- cpp/src/arrow/csv/writer_benchmark.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/csv/writer_benchmark.cc b/cpp/src/arrow/csv/writer_benchmark.cc index 54c0f50613754..9baa00d48a6d2 100644 --- a/cpp/src/arrow/csv/writer_benchmark.cc +++ b/cpp/src/arrow/csv/writer_benchmark.cc @@ -97,7 +97,7 @@ void BenchmarkWriteCsv(benchmark::State& state, const WriteOptions& options, const RecordBatch& batch) { int64_t total_size = 0; - while (state.KeepRunning()) { + for (auto _ : state) { auto out = io::BufferOutputStream::Create().ValueOrDie(); ABORT_NOT_OK(WriteCSV(batch, options, out.get())); auto buffer = out->Finish().ValueOrDie(); @@ -106,6 +106,7 @@ void BenchmarkWriteCsv(benchmark::State& state, const WriteOptions& options, // byte size of the generated csv dataset state.SetBytesProcessed(total_size); + state.SetItemsProcessed(state.iterations() * batch.num_columns() * batch.num_rows()); state.counters["null_percent"] = static_cast(state.range(0)); }