mapleFU commented on code in PR #40876:
URL: https://github.com/apache/arrow/pull/40876#discussion_r1549824736
##########
cpp/src/parquet/encoding_benchmark.cc:
##########
@@ -1373,4 +1408,123 @@ BENCHMARK_DEFINE_F(BM_ArrowBinaryDict,
DecodeArrowNonNull_Dict)
BENCHMARK_REGISTER_F(BM_ArrowBinaryDict, DecodeArrowNonNull_Dict)
->Range(MIN_RANGE, MAX_RANGE);
+class BenchmarkDecodeArrowBoolean : public
BenchmarkDecodeArrowBase<BooleanType> {
+ public:
+ void InitDataInputs() final {
+ // Generate a random string dictionary without any nulls so that this
dataset can
+ // be used for benchmarking the DecodeArrowNonNull API
+ constexpr int repeat_factor = 8;
+ ::arrow::random::RandomArrayGenerator rag(0);
+ input_array_ =
+ rag.Boolean(num_values_, num_values_ / repeat_factor,
null_probability_);
+ valid_bits_ = input_array_->null_bitmap_data();
+
+ // Arrow uses a bitmap representation for boolean arrays,
+ // so, we uses this as "total_size" for the benchmark.
+ total_size_ = ::arrow::bit_util::BytesForBits(num_values_);
+
+ values_.reserve(num_values_);
+ const auto& boolean_array = static_cast<const
::arrow::BooleanArray&>(*input_array_);
+ for (int64_t i = 0; i < boolean_array.length(); i++) {
+ values_.push_back(boolean_array.Value(i));
+ }
+ }
+
+ typename EncodingTraits<BooleanType>::Accumulator CreateAccumulator() final {
+ return typename EncodingTraits<BooleanType>::Accumulator();
+ }
+
+ void DoEncodeLowLevel() final { ParquetException::NYI(); }
+
+ void DecodeArrowWithNullDenseBenchmark(benchmark::State& state);
+
+ protected:
+ double null_probability_ = 0.0;
+};
+
+void BenchmarkDecodeArrowBoolean::DecodeArrowWithNullDenseBenchmark(
+ benchmark::State& state) {
+ // Change null_probability
+ null_probability_ = static_cast<double>(state.range(1)) / 100;
+ InitDataInputs();
+ this->DoEncodeArrow();
+ int num_values_with_nulls = this->num_values_;
+
+ for (auto _ : state) {
+ auto decoder = this->InitializeDecoder();
+ auto acc = this->CreateAccumulator();
+ decoder->DecodeArrow(
+ num_values_with_nulls,
+ /*null_count=*/static_cast<int>(this->input_array_->null_count()),
+ this->valid_bits_, 0, &acc);
+ }
+ state.SetBytesProcessed(state.iterations() *
static_cast<int64_t>(total_size_));
+}
+
+class BM_DecodeArrowBooleanPlain : public BenchmarkDecodeArrowBoolean {
+ public:
+ void DoEncodeArrow() final {
+ auto encoder = MakeTypedEncoder<BooleanType>(Encoding::PLAIN);
+ encoder->Put(*input_array_);
+ buffer_ = encoder->FlushValues();
+ }
+
+ std::unique_ptr<TypedDecoder<BooleanType>> InitializeDecoder() override {
+ auto decoder = MakeTypedDecoder<BooleanType>(Encoding::PLAIN);
+ decoder->SetData(num_values_, buffer_->data(),
static_cast<int>(buffer_->size()));
+ return decoder;
+ }
+};
+
+class BM_DecodeArrowBooleanRle : public BenchmarkDecodeArrowBoolean {
+ public:
+ void DoEncodeArrow() final {
+ auto encoder = MakeTypedEncoder<BooleanType>(Encoding::RLE);
+ encoder->Put(*input_array_);
+ buffer_ = encoder->FlushValues();
+ }
+
+ std::unique_ptr<TypedDecoder<BooleanType>> InitializeDecoder() override {
+ auto decoder = MakeTypedDecoder<BooleanType>(Encoding::RLE);
+ decoder->SetData(num_values_, buffer_->data(),
static_cast<int>(buffer_->size()));
+ return decoder;
+ }
+};
+
+static void BooleanWithNullCustomArguments(benchmark::internal::Benchmark* b) {
+ b->ArgsProduct({
+ benchmark::CreateRange(MIN_RANGE, MAX_RANGE, /*multi=*/2),
Review Comment:
change multi to 4 now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]