iChauster commented on code in PR #13426: URL: https://github.com/apache/arrow/pull/13426#discussion_r923502821
########## cpp/src/arrow/compute/exec/asof_join_benchmark.cc: ########## @@ -0,0 +1,159 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include <boost/process.hpp> +#include <string> + +#include "benchmark/benchmark.h" + +#include "arrow/compute/exec/test_util.h" +#include "arrow/dataset/file_parquet.h" +#include "arrow/table.h" +#include "arrow/testing/future_util.h" + +namespace arrow { +namespace compute { + +static const char* time_col = "time"; +static const char* key_col = "id"; +const int default_start = 0; +const int default_end = 500; + +struct TableSourceNodeStats { + ExecNode* execNode; + size_t total_rows; + size_t total_bytes; +}; + +static TableSourceNodeStats MakeTableSourceNode( + std::shared_ptr<arrow::compute::ExecPlan>& plan, TableGenerationProperties properties, + int batch_size) { + std::shared_ptr<Table> table = MakeRandomTable(properties); + size_t row_size = sizeof(double) * (table.get()->schema()->num_fields() - 2) + + sizeof(int64_t) + sizeof(int32_t); + size_t rows = table.get()->num_rows(); + return {*arrow::compute::MakeExecNode( + "table_source", // registered type + plan.get(), // execution plan + {}, // inputs + arrow::compute::TableSourceNodeOptions(table, batch_size)), + rows, row_size * rows}; +} + +static void TableJoinOverhead(benchmark::State& state, + TableGenerationProperties left_table_properties, + int left_table_batch_size, + TableGenerationProperties right_table_properties, + int right_table_batch_size, int num_right_tables, + std::string factory_name, ExecNodeOptions& options) { + ExecContext ctx(default_memory_pool(), arrow::internal::GetCpuThreadPool()); + size_t rows = 0; + size_t bytes = 0; + for (auto _ : state) { + state.PauseTiming(); + + ASSERT_OK_AND_ASSIGN(std::shared_ptr<arrow::compute::ExecPlan> plan, + ExecPlan::Make(&ctx)); + left_table_properties.column_prefix = "lt"; + left_table_properties.seed = 0; Review Comment: Refactored as above ^ -- 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]
