From 1576991177ba97a4b2ff6c45950f1fa6e9aa678c Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Tue, 20 Feb 2024 16:51:06 +0000 Subject: [PATCH] fix some warnings --- test/complexity_test.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/complexity_test.cc b/test/complexity_test.cc index 0c159cd2..fb4ad1ad 100644 --- a/test/complexity_test.cc +++ b/test/complexity_test.cc @@ -71,7 +71,7 @@ void BM_Complexity_O1(benchmark::State &state) { for (auto _ : state) { // This test requires a non-zero CPU time to avoid divide-by-zero benchmark::DoNotOptimize(state.iterations()); - double tmp = state.iterations(); + long tmp = state.iterations(); benchmark::DoNotOptimize(tmp); for (benchmark::IterationCount i = 0; i < state.iterations(); ++i) { benchmark::DoNotOptimize(state.iterations()); @@ -120,7 +120,7 @@ void BM_Complexity_O_N(benchmark::State &state) { for (auto _ : state) { // This test requires a non-zero CPU time to avoid divide-by-zero benchmark::DoNotOptimize(state.iterations()); - double tmp = state.iterations(); + long tmp = state.iterations(); benchmark::DoNotOptimize(tmp); for (benchmark::IterationCount i = 0; i < state.iterations(); ++i) { benchmark::DoNotOptimize(state.iterations()); @@ -129,7 +129,7 @@ void BM_Complexity_O_N(benchmark::State &state) { } // 1ns per iteration per entry - state.SetIterationTime(state.range(0) * 42 * 1e-9); + state.SetIterationTime(static_cast(state.range(0)) * 42.0 * 1e-9); } state.SetComplexityN(state.range(0)); } @@ -178,7 +178,7 @@ static void BM_Complexity_O_N_log_N(benchmark::State &state) { for (auto _ : state) { // This test requires a non-zero CPU time to avoid divide-by-zero benchmark::DoNotOptimize(state.iterations()); - double tmp = state.iterations(); + long tmp = state.iterations(); benchmark::DoNotOptimize(tmp); for (benchmark::IterationCount i = 0; i < state.iterations(); ++i) { benchmark::DoNotOptimize(state.iterations()); @@ -186,8 +186,8 @@ static void BM_Complexity_O_N_log_N(benchmark::State &state) { benchmark::DoNotOptimize(tmp); } - state.SetIterationTime(state.range(0) * kLog2E * std::log(state.range(0)) * - 42 * 1e-9); + state.SetIterationTime(static_cast(state.range(0)) * kLog2E * + std::log(state.range(0)) * 42.0 * 1e-9); } state.SetComplexityN(state.range(0)); } @@ -238,7 +238,7 @@ void BM_ComplexityCaptureArgs(benchmark::State &state, int n) { for (auto _ : state) { // This test requires a non-zero CPU time to avoid divide-by-zero benchmark::DoNotOptimize(state.iterations()); - double tmp = state.iterations(); + long tmp = state.iterations(); benchmark::DoNotOptimize(tmp); for (benchmark::IterationCount i = 0; i < state.iterations(); ++i) { benchmark::DoNotOptimize(state.iterations()); @@ -246,7 +246,7 @@ void BM_ComplexityCaptureArgs(benchmark::State &state, int n) { benchmark::DoNotOptimize(tmp); } - state.SetIterationTime(state.range(0) * 42 * 1e-9); + state.SetIterationTime(static_cast(state.range(0)) * 42.0 * 1e-9); } state.SetComplexityN(n); }