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

Function BatchToTensorSimple

cpp/src/arrow/tensor_benchmark.cc:30–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template <typename ValueType>
30static 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
55template <typename ValueType, bool row_major>
56static void TableToTensorSimple(benchmark::State& state) {

Callers

nothing calls this directly

Calls 7

to_stringFunction · 0.85
push_backMethod · 0.80
type_singletonFunction · 0.70
fieldFunction · 0.70
MakeFunction · 0.70
ArrayOfMethod · 0.45
byte_widthMethod · 0.45

Tested by

no test coverage detected