| 783 | } |
| 784 | |
| 785 | void 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 | |
| 810 | static void BM_DeltaLengthEncodingByteArray(benchmark::State& state) { |
| 811 | EncodingByteArrayBenchmark(state, Encoding::DELTA_LENGTH_BYTE_ARRAY); |
no test coverage detected