From f15f332fd1ae10ae6d13d816af9bcf3b196974cc Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Mon, 6 Feb 2023 16:38:53 +0000 Subject: [PATCH] get rid of some deprecation warnings from tests --- test/benchmark_test.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/benchmark_test.cc b/test/benchmark_test.cc index ce233ece..94590d5e 100644 --- a/test/benchmark_test.cc +++ b/test/benchmark_test.cc @@ -75,7 +75,8 @@ BENCHMARK_RANGE(BM_CalculatePiRange, 1, 1024 * 1024); static void BM_CalculatePi(benchmark::State& state) { static const int depth = 1024; for (auto _ : state) { - benchmark::DoNotOptimize(CalculatePi(static_cast(depth))); + double pi = CalculatePi(static_cast(depth)); + benchmark::DoNotOptimize(pi); } } BENCHMARK(BM_CalculatePi)->Threads(8); @@ -124,7 +125,10 @@ static void BM_StringCompare(benchmark::State& state) { size_t len = static_cast(state.range(0)); std::string s1(len, '-'); std::string s2(len, '-'); - for (auto _ : state) benchmark::DoNotOptimize(s1.compare(s2)); + for (auto _ : state) { + auto comp = s1.compare(s2); + benchmark::DoNotOptimize(comp); + } } BENCHMARK(BM_StringCompare)->Range(1, 1 << 20);