| 244 | } |
| 245 | |
| 246 | static 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 | |
| 265 | static void Constants(benchmark::State& state) { // NOLINT non-const reference |
| 266 | BasicDecimal128 d1(-546, 123), d2(-123, 456); |
nothing calls this directly
no test coverage detected