Add pow benchmark
As for exp/exp2 benchmark, this patch add two benchmark for pow:
one which measures thoughput and one which measures latency.
The input data is the same as powf.
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: I04335fac9e76fb3f39935323dacf6b7be6a6f917
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index 7d258f7..c3f14c8 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -331,6 +331,9 @@
#include "powf_input.cpp"
+static const std::vector<std::pair<double, double>> pow_input
+ (powf_input.begin(), powf_input.end());
+
static void BM_math_powf_speccpu2006(benchmark::State& state) {
f = 0.0;
auto cin = powf_input.cbegin();
@@ -353,6 +356,28 @@
}
BIONIC_BENCHMARK(BM_math_powf_speccpu2017_latency);
+static void BM_math_pow_speccpu2006(benchmark::State& state) {
+ d = 0.0;
+ auto cin = pow_input.cbegin();
+ for (auto _ : state) {
+ f = pow(cin->first, cin->second);
+ if (++cin == pow_input.cend())
+ cin = pow_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_pow_speccpu2006);
+
+static void BM_math_pow_speccpu2017_latency(benchmark::State& state) {
+ d = 0.0;
+ auto cin = pow_input.cbegin();
+ for (auto _ : state) {
+ d = powf(d * zero + cin->first, cin->second);
+ if (++cin == pow_input.cend())
+ cin = pow_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_pow_speccpu2017_latency);
+
#include "logf_input.cpp"
static const std::vector<double> log_input (logf_input.begin(),