Skip to content

Commit

Permalink
apacheGH-39666: [C++] Ensure CSV and JSON benchmarks present a bytes/…
Browse files Browse the repository at this point in the history
…s or items/s metric (apache#39764)

### Rationale for this change

Some of our microbenchmarks only present an iteration time in (nano,micro...)seconds. That is usually tedious to read and difficult to interpret.

### What changes are included in this PR?

Ensure that benchmarks present a items/seconds and/or a bytes/seconds metric where that makes sense.

### Are these changes tested?

Manually.

### Are there any user-facing changes?

No.
* Closes: apache#39666

Authored-by: Antoine Pitrou <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
pitrou authored and dgreiss committed Feb 17, 2024
1 parent c8f3cc9 commit 30989c3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpp/src/arrow/csv/writer_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<double>(state.range(0));
}

Expand Down

0 comments on commit 30989c3

Please sign in to comment.