Add powf benchmark
As for expf/exp2f benchmark, this patch add two benchmark for powf:
one which measures thoughput and one which measures latency.
The input data is based on a reduced trace from 2.3 billion samples
extracted from specpu2017 521.wrf_r benchmark.
Test: ran 32-bit and 64-bit x86 tests on host
Change-Id: Id8943d90dd5452146e55fb75708daaf7bf0e25fa
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index 39f622b..f7c11d5 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -278,3 +278,27 @@
}
}
BIONIC_BENCHMARK(BM_math_exp2f_speccpu2017_latency);
+
+#include "powf_input.cpp"
+
+static void BM_math_powf_speccpu2006(benchmark::State& state) {
+ f = 0.0;
+ auto cin = powf_input.cbegin();
+ for (auto _ : state) {
+ f = powf(cin->first, cin->second);
+ if (++cin == powf_input.cend())
+ cin = powf_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_powf_speccpu2006);
+
+static void BM_math_powf_speccpu2017_latency(benchmark::State& state) {
+ f = 0.0;
+ auto cin = powf_input.cbegin();
+ for (auto _ : state) {
+ f = powf(f * zero + cin->first, cin->second);
+ if (++cin == powf_input.cend())
+ cin = powf_input.cbegin();
+ }
+}
+BIONIC_BENCHMARK(BM_math_powf_speccpu2017_latency);