MCPcopy Create free account
hub / github.com/apache/arrow / DecodingByteArrayBenchmark

Function DecodingByteArrayBenchmark

cpp/src/parquet/encoding_benchmark.cc:818–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816}
817
818void DecodingByteArrayBenchmark(benchmark::State& state, Encoding::type encoding) {
819 ::arrow::random::RandomArrayGenerator rag(0);
820 int32_t max_length = static_cast<int32_t>(state.range(0));
821 int32_t array_size = static_cast<int32_t>(state.range(1));
822 // Using arrow to write, because we just benchmark decoding here.
823 auto array =
824 rag.String(/* size */ array_size, /* min_length */ 0, /* max_length */ max_length,
825 /* null_probability */ 0);
826 const auto array_actual =
827 ::arrow::internal::checked_pointer_cast<::arrow::StringArray>(array);
828 auto encoder = MakeTypedEncoder<ByteArrayType>(encoding);
829 encoder->Put(*array);
830 std::shared_ptr<Buffer> buf = encoder->FlushValues();
831
832 std::vector<ByteArray> values;
833 values.resize(array->length());
834 for (auto _ : state) {
835 auto decoder = MakeTypedDecoder<ByteArrayType>(encoding);
836 decoder->SetData(static_cast<int>(array->length()), buf->data(),
837 static_cast<int>(buf->size()));
838 decoder->Decode(values.data(), static_cast<int>(values.size()));
839 ::benchmark::DoNotOptimize(values);
840 }
841 state.SetItemsProcessed(state.iterations() * array->length());
842 state.SetBytesProcessed(state.iterations() * (array_actual->value_data()->size() +
843 array_actual->value_offsets()->size()));
844}
845
846static void BM_PlainDecodingByteArray(benchmark::State& state) {
847 DecodingByteArrayBenchmark(state, Encoding::PLAIN);

Callers 2

Calls 11

resizeMethod · 0.80
value_offsetsMethod · 0.80
StringMethod · 0.45
PutMethod · 0.45
FlushValuesMethod · 0.45
lengthMethod · 0.45
SetDataMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
DecodeMethod · 0.45
value_dataMethod · 0.45

Tested by

no test coverage detected