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

Function UnaryOp

cpp/src/arrow/util/decimal_benchmark.cc:246–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246static void UnaryOp(benchmark::State& state) { // NOLINT non-const reference
247 std::vector<BasicDecimal128> v;
248 for (int x = 0; x < kValueSize; x++) {
249 v.emplace_back(100 + x, 100 + x);
250 }
251
252 static_assert(kValueSize % 2 == 0,
253 "kValueSize needs to be a multiple of 2 to avoid out-of-bounds accesses");
254 for (auto _ : state) {
255 for (int x = 0; x < kValueSize; x += 2) {
256 auto abs = v[x].Abs();
257 benchmark::DoNotOptimize(abs);
258 auto negate = v[x + 1].Negate();
259 benchmark::DoNotOptimize(negate);
260 }
261 }
262 state.SetItemsProcessed(state.iterations() * kValueSize);
263}
264
265static void Constants(benchmark::State& state) { // NOLINT non-const reference
266 BasicDecimal128 d1(-546, 123), d2(-123, 456);

Callers

nothing calls this directly

Calls 3

emplace_backMethod · 0.80
AbsMethod · 0.80
NegateMethod · 0.80

Tested by

no test coverage detected