| 28 | |
| 29 | template <typename ValueType> |
| 30 | static void BatchToTensorSimple(benchmark::State& state) { |
| 31 | using CType = typename ValueType::c_type; |
| 32 | std::shared_ptr<DataType> ty = TypeTraits<ValueType>::type_singleton(); |
| 33 | |
| 34 | const int64_t num_cols = state.range(1); |
| 35 | const int64_t num_rows = state.range(0) / num_cols / sizeof(CType); |
| 36 | arrow::random::RandomArrayGenerator gen_{42}; |
| 37 | |
| 38 | std::vector<std::shared_ptr<Field>> fields = {}; |
| 39 | std::vector<std::shared_ptr<Array>> columns = {}; |
| 40 | |
| 41 | for (int64_t i = 0; i < num_cols; ++i) { |
| 42 | fields.push_back(field("f" + std::to_string(i), ty)); |
| 43 | columns.push_back(gen_.ArrayOf(ty, num_rows)); |
| 44 | } |
| 45 | auto schema = std::make_shared<Schema>(std::move(fields)); |
| 46 | auto batch = RecordBatch::Make(schema, num_rows, columns); |
| 47 | |
| 48 | for (auto _ : state) { |
| 49 | ASSERT_OK_AND_ASSIGN(auto tensor, batch->ToTensor()); |
| 50 | } |
| 51 | state.SetItemsProcessed(state.iterations() * num_rows * num_cols); |
| 52 | state.SetBytesProcessed(state.iterations() * ty->byte_width() * num_rows * num_cols); |
| 53 | } |
| 54 | |
| 55 | template <typename ValueType, bool row_major> |
| 56 | static void TableToTensorSimple(benchmark::State& state) { |
nothing calls this directly
no test coverage detected