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

Function BenchmarkVectorPushBack

cpp/src/arrow/util/small_vector_benchmark.cc:177–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175// With ARROW_NOINLINE, try to make sure the number of items is not constant-propagated
176template <typename Vector>
177ARROW_NOINLINE void BenchmarkVectorPushBack(benchmark::State& state, const int nitems) {
178 using T = typename Vector::value_type;
179 constexpr int kNumIters = 1000;
180
181 ARROW_CHECK_LE(static_cast<size_t>(nitems), Vector{}.max_size());
182
183 for (auto _ : state) {
184 int64_t dummy = 0;
185 for (int i = 0; i < kNumIters; ++i) {
186 Vector vec;
187 vec.reserve(nitems);
188 for (int j = 0; j < nitems; ++j) {
189 vec.push_back(ValueInitializer<T>(j));
190 }
191 dummy += reinterpret_cast<intptr_t>(vec.data());
192 benchmark::ClobberMemory();
193 }
194 benchmark::DoNotOptimize(dummy);
195 }
196
197 state.SetItemsProcessed(state.iterations() * kNumIters * nitems);
198}
199
200template <typename Vector>
201void ShortVectorPushBack(benchmark::State& state) {

Callers

nothing calls this directly

Calls 4

push_backMethod · 0.80
max_sizeMethod · 0.45
reserveMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected