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

Function BatchToTensorSimple

cpp/src/arrow/tensor_benchmark.cc:29–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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