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

Function EncodingByteArrayBenchmark

cpp/src/parquet/encoding_benchmark.cc:785–808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783}
784
785void EncodingByteArrayBenchmark(benchmark::State& state, Encoding::type encoding) {
786 ::arrow::random::RandomArrayGenerator rag(0);
787 // Using arrow generator to generate random data.
788 int32_t max_length = static_cast<int32_t>(state.range(0));
789 int32_t array_size = static_cast<int32_t>(state.range(1));
790 auto array =
791 rag.String(/* size */ array_size, /* min_length */ 0, /* max_length */ max_length,
792 /* null_probability */ 0);
793 const auto array_actual =
794 ::arrow::internal::checked_pointer_cast<::arrow::StringArray>(array);
795 auto encoder = MakeTypedEncoder<ByteArrayType>(encoding);
796 std::vector<ByteArray> values;
797 for (int i = 0; i < array_actual->length(); ++i) {
798 values.emplace_back(array_actual->GetView(i));
799 }
800
801 for (auto _ : state) {
802 encoder->Put(values.data(), static_cast<int>(values.size()));
803 encoder->FlushValues();
804 }
805 state.SetItemsProcessed(state.iterations() * array_actual->length());
806 state.SetBytesProcessed(state.iterations() * (array_actual->value_data()->size() +
807 array_actual->value_offsets()->size()));
808}
809
810static void BM_DeltaLengthEncodingByteArray(benchmark::State& state) {
811 EncodingByteArrayBenchmark(state, Encoding::DELTA_LENGTH_BYTE_ARRAY);

Callers 2

Calls 10

emplace_backMethod · 0.80
value_offsetsMethod · 0.80
StringMethod · 0.45
lengthMethod · 0.45
GetViewMethod · 0.45
PutMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
FlushValuesMethod · 0.45
value_dataMethod · 0.45

Tested by

no test coverage detected