From 4f6ecb9ca958f24ce44939c832f54ff754e3e6ae Mon Sep 17 00:00:00 2001 From: "Pavel I. Kryukov" Date: Thu, 28 Feb 2019 00:43:23 +0300 Subject: [PATCH] Remove branch from benchmark --- benchmark/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmark/main.cpp b/benchmark/main.cpp index 437a9b6..55b9bc7 100644 --- a/benchmark/main.cpp +++ b/benchmark/main.cpp @@ -27,14 +27,14 @@ struct A { - int x; - int y; - int z; - int w; + int32_t x; + int32_t y; + int32_t z; + int32_t w; }; -static const constexpr size_t CAPACITY = 8ull << 24ull; -static const constexpr size_t MAX_STRIDE = 16 * 64 / sizeof(int); +static const constexpr size_t CAPACITY = 1ull << 28ull; +static const constexpr size_t MAX_STRIDE = 1024; static const constexpr size_t ITERATIONS = CAPACITY / MAX_STRIDE; template typename Container> @@ -51,8 +51,8 @@ static void StridedAccess(benchmark::State& state) size_t stride = state.range(0); for (auto _ : state) for (size_t j = 0, i = 0; j < ITERATIONS; ++j, i += stride) - (*storage)[i]->*(&A::x) += std::max({(*storage)[i]->*(&A::x), (*storage)[i]->*(&A::y), (*storage)[i]->*(&A::z)}); - state.SetBytesProcessed(int64_t(state.iterations()) * ITERATIONS * sizeof(int) * 3); + (*storage)[i]->*(&A::x) += (*storage)[i]->*(&A::y) << (*storage)[i]->*(&A::z); + state.SetBytesProcessed(int64_t(state.iterations()) * ITERATIONS * sizeof(int32_t) * 3); } BENCHMARK_TEMPLATE(StridedAccess, aoaoaott::AoSArray)->RangeMultiplier(2)->Range(1, MAX_STRIDE);