Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-15200: [C++] Created benchmarks for round kernels. #15201

Merged
merged 8 commits into from
Jan 10, 2023
Prev Previous commit
Next Next commit
Added Decimal tests for Round and disabled most round mode tests by d…
…efault.
  • Loading branch information
EpsilonPrime committed Jan 9, 2023
commit ef8260399912ec0a1b46bb96e4bc04ce1b339af5
14 changes: 13 additions & 1 deletion cpp/src/arrow/compute/kernels/scalar_round_benchmark.cc
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ static void Trunc(benchmark::State& state) {
RoundArrayBenchmark<FloatType, Mode>(state, "trunc");
}

#ifdef ALL_ROUND_BENCHMARKS
#define DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, TYPE) \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::DOWN)->Apply(SetRoundArgs); \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::UP)->Apply(SetRoundArgs); \
@@ -89,6 +90,12 @@ static void Trunc(benchmark::State& state) {
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::HALF_TOWARDS_INFINITY)->Apply(SetRoundArgs); \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::HALF_TO_EVEN)->Apply(SetRoundArgs); \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::HALF_TO_ODD)->Apply(SetRoundArgs)
#else
#define DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, TYPE) \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::DOWN)->Apply(SetRoundArgs); \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::HALF_TOWARDS_ZERO)->Apply(SetRoundArgs); \
BENCHMARK_TEMPLATE(OP, TYPE, RoundMode::HALF_TO_ODD)->Apply(SetRoundArgs)
#endif

#define DECLARE_ROUND_BENCHMARKS(OP) \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, Int64Type); \
@@ -100,11 +107,16 @@ static void Trunc(benchmark::State& state) {
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, UInt16Type); \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, UInt8Type); \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, FloatType); \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, DoubleType)
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, DoubleType);

#define DECLARE_DECIMAL_ROUND_BENCHMARKS(OP) \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, Decimal128Type); \
DECLARE_ROUND_BENCHMARKS_WITH_ROUNDMODE(OP, Decimal256Type)

DECLARE_ROUND_BENCHMARKS(Ceil);
DECLARE_ROUND_BENCHMARKS(Floor);
DECLARE_ROUND_BENCHMARKS(Round);
DECLARE_DECIMAL_ROUND_BENCHMARKS(Round);
DECLARE_ROUND_BENCHMARKS(Trunc);

} // namespace compute