Skip to content

Commit

Permalink
Output benchmark param values
Browse files Browse the repository at this point in the history
  • Loading branch information
benibus committed Aug 8, 2023
1 parent c7c3059 commit 0b75284
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cpp/src/arrow/type_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <algorithm>
#include <cstdint>
#include <exception>
#include <optional>
#include <random>
#include <string>
#include <vector>
Expand Down Expand Up @@ -474,7 +475,8 @@ static std::shared_ptr<Table> ToTable(const std::shared_ptr<Array>& array,

template <typename T>
static void BenchmarkFieldPathGet(benchmark::State& state, // NOLINT non-const reference
const T& input, int num_columns) {
const T& input, int num_columns,
std::optional<int> num_chunks = {}) {
// Reassigning a single FieldPath var within each iteration's scope seems to be costly
// enough to influence the timings, so we preprocess them.
std::vector<FieldPath> paths(num_columns);
Expand All @@ -489,6 +491,10 @@ static void BenchmarkFieldPathGet(benchmark::State& state, // NOLINT non-const
}

state.SetItemsProcessed(state.iterations() * num_columns);
state.counters["num_columns"] = num_columns;
if (num_chunks.has_value()) {
state.counters["num_chunks"] = num_chunks.value();
}
}

static void FieldPathGetFromWideArray(
Expand Down Expand Up @@ -519,14 +525,14 @@ static void FieldPathGetFromWideChunkedArray(
// proportion means more chunks)
const double chunk_proportion = state.range(0) / 100.0;
auto chunked_array = ToChunked(GenerateTestArray(kNumColumns), chunk_proportion);
BenchmarkFieldPathGet(state, *chunked_array, kNumColumns);
BenchmarkFieldPathGet(state, *chunked_array, kNumColumns, chunked_array->num_chunks());
}

static void FieldPathGetFromWideTable(
benchmark::State& state) { // NOLINT non-const reference
constexpr int kNumColumns = 10000;
auto table = ToTable(GenerateTestArray(kNumColumns));
BenchmarkFieldPathGet(state, *table, kNumColumns);
BenchmarkFieldPathGet(state, *table, kNumColumns, table->column(0)->num_chunks());
}

BENCHMARK(TypeEqualsSimple);
Expand Down

0 comments on commit 0b75284

Please sign in to comment.