Fix benchmark warning: -Wdeprecated-declarations

Example:

apps/benchmarks/settings/access.cpp: In function ‘void {anonymous}::localStatic(benchmark::State&)’:
apps/benchmarks/settings/access.cpp:43:37: warning: ‘typename std::enable_if<(std::is_trivially_copyable<_Tp>::value && (sizeof (Tp) <= sizeof (Tp*)))>::type benchmark::DoNotOptimize(const Tp&) [with Tp = float; typename std::enable_if<(std::is_trivially_copyable<_Tp>::value && (sizeof (Tp) <= sizeof (Tp*)))>::type = void]’ is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks [-Wdeprecated-declarations]
   43 |             benchmark::DoNotOptimize(v);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~
fix-osga-rotate-wildly
elsid 10 months ago
parent 2a41811c83
commit 9b412bc802
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -38,7 +38,7 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
static const float v = Settings::Manager::getFloat("sky blending start", "Fog"); static float v = Settings::Manager::getFloat("sky blending start", "Fog");
benchmark::DoNotOptimize(v); benchmark::DoNotOptimize(v);
} }
} }
@ -47,8 +47,8 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
static const float v1 = Settings::Manager::getFloat("near clip", "Camera"); static float v1 = Settings::Manager::getFloat("near clip", "Camera");
static const bool v2 = Settings::Manager::getBool("transparent postpass", "Post Processing"); static bool v2 = Settings::Manager::getBool("transparent postpass", "Post Processing");
benchmark::DoNotOptimize(v1); benchmark::DoNotOptimize(v1);
benchmark::DoNotOptimize(v2); benchmark::DoNotOptimize(v2);
} }
@ -58,9 +58,9 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
static const float v1 = Settings::Manager::getFloat("near clip", "Camera"); static float v1 = Settings::Manager::getFloat("near clip", "Camera");
static const bool v2 = Settings::Manager::getBool("transparent postpass", "Post Processing"); static bool v2 = Settings::Manager::getBool("transparent postpass", "Post Processing");
static const int v3 = Settings::Manager::getInt("reflection detail", "Water"); static int v3 = Settings::Manager::getInt("reflection detail", "Water");
benchmark::DoNotOptimize(v1); benchmark::DoNotOptimize(v1);
benchmark::DoNotOptimize(v2); benchmark::DoNotOptimize(v2);
benchmark::DoNotOptimize(v3); benchmark::DoNotOptimize(v3);
@ -71,7 +71,8 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
benchmark::DoNotOptimize(Settings::fog().mSkyBlendingStart.get()); float v = Settings::fog().mSkyBlendingStart.get();
benchmark::DoNotOptimize(v);
} }
} }
@ -79,8 +80,10 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
benchmark::DoNotOptimize(Settings::postProcessing().mTransparentPostpass.get()); bool v1 = Settings::postProcessing().mTransparentPostpass.get();
benchmark::DoNotOptimize(Settings::camera().mNearClip.get()); float v2 = Settings::camera().mNearClip.get();
benchmark::DoNotOptimize(v1);
benchmark::DoNotOptimize(v2);
} }
} }
@ -88,9 +91,12 @@ namespace
{ {
for (auto _ : state) for (auto _ : state)
{ {
benchmark::DoNotOptimize(Settings::postProcessing().mTransparentPostpass.get()); bool v1 = Settings::postProcessing().mTransparentPostpass.get();
benchmark::DoNotOptimize(Settings::camera().mNearClip.get()); float v2 = Settings::camera().mNearClip.get();
benchmark::DoNotOptimize(Settings::water().mReflectionDetail.get()); int v3 = Settings::water().mReflectionDetail.get();
benchmark::DoNotOptimize(v1);
benchmark::DoNotOptimize(v2);
benchmark::DoNotOptimize(v3);
} }
} }

Loading…
Cancel
Save