Cleanup data initialization of benchmarks
This commit is contained in:
@@ -7,14 +7,17 @@
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
void init_x(std::vector<float> &x) {
|
||||
for (size_t i = 0; i < x.size(); ++i) {
|
||||
x[i] = (i % 360) * 0.0174533f; // degrees to radians
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Backend>
|
||||
static void benchmark_sinf(benchmark::State &state) {
|
||||
const size_t N = static_cast<size_t>(state.range(0));
|
||||
std::vector<float> x(N), s(N);
|
||||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
x[i] = (i % 360) * 0.0174533f; // degrees to radians
|
||||
}
|
||||
init_x(x);
|
||||
|
||||
Backend backend;
|
||||
|
||||
@@ -39,10 +42,7 @@ template <typename Backend>
|
||||
static void benchmark_cosf(benchmark::State &state) {
|
||||
const size_t N = static_cast<size_t>(state.range(0));
|
||||
std::vector<float> x(N), c(N);
|
||||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
x[i] = (i % 360) * 0.0174533f;
|
||||
}
|
||||
init_x(x);
|
||||
|
||||
Backend backend;
|
||||
|
||||
@@ -67,10 +67,7 @@ template <typename Backend>
|
||||
static void benchmark_sincosf(benchmark::State &state) {
|
||||
const size_t N = static_cast<size_t>(state.range(0));
|
||||
std::vector<float> x(N), s(N), c(N);
|
||||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
x[i] = (i % 360) * 0.0174533f;
|
||||
}
|
||||
init_x(x);
|
||||
|
||||
Backend backend;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user