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

Function BM_DecodingByteArraySpaced

cpp/src/parquet/encoding_benchmark.cc:859–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857BENCHMARK(BM_DeltaLengthDecodingByteArray)->Apply(ByteArrayCustomArguments);
858
859static void BM_DecodingByteArraySpaced(benchmark::State& state, Encoding::type encoding) {
860 const double null_percent = 0.02;
861
862 auto rand = ::arrow::random::RandomArrayGenerator(0);
863 int32_t max_length = static_cast<int32_t>(state.range(0));
864 int32_t num_values = static_cast<int32_t>(state.range(1));
865 const auto array = rand.String(num_values, /* min_length */ 0,
866 /* max_length */ max_length, null_percent);
867 const auto valid_bits = array->null_bitmap_data();
868 const int null_count = static_cast<int>(array->null_count());
869 const auto array_actual =
870 ::arrow::internal::checked_pointer_cast<::arrow::StringArray>(array);
871
872 std::vector<ByteArray> byte_arrays;
873 byte_arrays.reserve(array_actual->length());
874 for (int i = 0; i < array_actual->length(); ++i) {
875 byte_arrays.emplace_back(array_actual->GetView(i));
876 }
877
878 auto encoder = MakeTypedEncoder<ByteArrayType>(encoding);
879 encoder->PutSpaced(byte_arrays.data(), num_values, valid_bits, 0);
880 std::shared_ptr<Buffer> buf = encoder->FlushValues();
881
882 auto decoder = MakeTypedDecoder<ByteArrayType>(encoding);
883 std::vector<uint8_t> decode_values(num_values * sizeof(ByteArray));
884 auto decode_buf = reinterpret_cast<ByteArray*>(decode_values.data());
885 for (auto _ : state) {
886 decoder->SetData(num_values - null_count, buf->data(), static_cast<int>(buf->size()));
887 decoder->DecodeSpaced(decode_buf, num_values, null_count, valid_bits, 0);
888 ::benchmark::DoNotOptimize(decode_buf);
889 }
890 state.counters["null_percent"] = null_percent * 100;
891 state.SetItemsProcessed(state.iterations() * array_actual->length());
892 state.SetBytesProcessed(state.iterations() * (array_actual->value_data()->size() +
893 array_actual->value_offsets()->size()));
894}
895
896static void BM_PlainDecodingSpacedByteArray(benchmark::State& state) {
897 BM_DecodingByteArraySpaced(state, Encoding::PLAIN);

Calls 14

emplace_backMethod · 0.80
value_offsetsMethod · 0.80
StringMethod · 0.45
null_countMethod · 0.45
reserveMethod · 0.45
lengthMethod · 0.45
GetViewMethod · 0.45
PutSpacedMethod · 0.45
dataMethod · 0.45
FlushValuesMethod · 0.45
SetDataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected