| 54 | |
| 55 | template <typename ValueType, bool row_major> |
| 56 | static void TableToTensorSimple(benchmark::State& state) { |
| 57 | using CType = typename ValueType::c_type; |
| 58 | std::shared_ptr<DataType> ty = TypeTraits<ValueType>::type_singleton(); |
| 59 | |
| 60 | const int64_t num_cols = state.range(1); |
| 61 | const int64_t num_rows = state.range(0) / num_cols / sizeof(CType); |
| 62 | arrow::random::RandomArrayGenerator gen_{42}; |
| 63 | |
| 64 | std::vector<std::shared_ptr<Field>> fields = {}; |
| 65 | std::vector<std::shared_ptr<ChunkedArray>> columns = {}; |
| 66 | |
| 67 | for (int64_t i = 0; i < num_cols; ++i) { |
| 68 | fields.push_back(field("f" + std::to_string(i), ty)); |
| 69 | const int64_t chunk1_len = num_rows / 2; |
| 70 | const int64_t chunk2_len = num_rows - chunk1_len; |
| 71 | ArrayVector arrays = {gen_.ArrayOf(ty, chunk1_len), gen_.ArrayOf(ty, chunk2_len)}; |
| 72 | auto chunks = std::make_shared<ChunkedArray>(arrays, ty); |
| 73 | columns.push_back(chunks); |
| 74 | } |
| 75 | auto schema = std::make_shared<Schema>(std::move(fields)); |
| 76 | auto table = Table::Make(schema, columns); |
| 77 | |
| 78 | for (auto _ : state) { |
| 79 | ASSERT_OK_AND_ASSIGN(auto tensor, |
| 80 | table->ToTensor(/*null_to_nan=*/false, /*row_major=*/row_major)); |
| 81 | } |
| 82 | state.SetItemsProcessed(state.iterations() * num_rows * num_cols); |
| 83 | state.SetBytesProcessed(state.iterations() * ty->byte_width() * num_rows * num_cols); |
| 84 | } |
| 85 | |
| 86 | void SetArgs(benchmark::internal::Benchmark* bench) { |
| 87 | for (int64_t size : {kL1Size, kL2Size}) { |
nothing calls this directly
no test coverage detected