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

Function BM_CastDispatchBaseline

cpp/src/arrow/compute/function_benchmark.cc:67–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67void BM_CastDispatchBaseline(benchmark::State& state) {
68 // Repeatedly invoke a trivial Cast with all dispatch outside the hot loop
69 random::RandomArrayGenerator rag(kSeed);
70
71 auto int_array = rag.Int64(1, 0, 1 << 20);
72 auto double_type = float64();
73 CastOptions cast_options;
74 cast_options.to_type = double_type;
75 ASSERT_OK_AND_ASSIGN(auto cast_function, internal::GetCastFunction(*double_type));
76 ASSERT_OK_AND_ASSIGN(auto cast_kernel,
77 cast_function->DispatchExact({int_array->type()}));
78 const auto& exec = static_cast<const ScalarKernel*>(cast_kernel)->exec;
79
80 ExecContext exec_context;
81 KernelContext kernel_context(&exec_context);
82 auto cast_state = cast_kernel
83 ->init(&kernel_context,
84 KernelInitArgs{cast_kernel, {double_type}, &cast_options})
85 .ValueOrDie();
86 kernel_context.SetState(cast_state.get());
87
88 ExecSpan input({ExecValue(*int_array->data())}, 1);
89 ExecResult result;
90 ASSERT_OK_AND_ASSIGN(std::shared_ptr<Array> result_space,
91 MakeArrayOfNull(double_type, 1));
92 result.array_span_mutable()->SetMembers(*result_space->data());
93 for (auto _ : state) {
94 ABORT_NOT_OK(exec(&kernel_context, input, &result));
95 }
96
97 state.SetItemsProcessed(state.iterations() * kScalarCount);
98}
99
100void BM_AddDispatch(benchmark::State& state) {
101 ExecContext exec_context;

Callers

nothing calls this directly

Calls 9

MakeArrayOfNullFunction · 0.85
ValueOrDieMethod · 0.80
SetMembersMethod · 0.80
ExecValueClass · 0.70
ASSERT_OK_AND_ASSIGNFunction · 0.70
Int64Method · 0.45
initMethod · 0.45
getMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected