| 62 | template <UnaryOp& Op, typename ArrowType, RoundMode Mode, |
| 63 | typename CType = typename ArrowType::c_type> |
| 64 | static void RoundArrayBenchmark(benchmark::State& state) { |
| 65 | RegressionArgs args(state); |
| 66 | |
| 67 | const int64_t array_size = args.size / sizeof(CType); |
| 68 | auto rand = random::RandomArrayGenerator(kSeed); |
| 69 | |
| 70 | // Choose values so as to avoid overflow on all ops and types. |
| 71 | auto min = static_cast<CType>(6); |
| 72 | auto max = static_cast<CType>(min + 15); |
| 73 | auto val = std::static_pointer_cast<NumericArray<ArrowType>>( |
| 74 | rand.Numeric<ArrowType>(array_size, min, max, args.null_proportion)); |
| 75 | RoundOptions options; |
| 76 | options.round_mode = static_cast<RoundMode>(Mode); |
| 77 | options.ndigits = 1; |
| 78 | |
| 79 | for (auto _ : state) { |
| 80 | ABORT_NOT_OK(Op(val, options, NULLPTR)); |
| 81 | } |
| 82 | state.SetItemsProcessed(state.iterations() * array_size); |
| 83 | } |
| 84 | |
| 85 | template <BinaryOp& Op, typename ArrowType, RoundMode Mode, |
| 86 | typename CType = typename ArrowType::c_type> |