From a6f22c51699b78116cac54a4ac95bbed710efbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 10 Dec 2023 21:22:43 +0100 Subject: [PATCH] Remove static instance of std::random_device in Benchmark::analyse_samples --- src/catch2/benchmark/detail/catch_stats.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 5867f1e1..a56edfc0 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -355,11 +355,6 @@ namespace Catch { unsigned int n_resamples, double* first, double* last) { - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS - static std::random_device entropy; - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - auto n = static_cast(last - first); // seriously, one can't use integral types without hell in C++ auto mean = &Detail::mean; @@ -367,7 +362,8 @@ namespace Catch { #if defined(CATCH_CONFIG_USE_ASYNC) auto Estimate = [=](double(*f)(double const*, double const*)) { - auto seed = entropy(); + std::random_device rd; + auto seed = rd(); return std::async(std::launch::async, [=] { SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); @@ -382,7 +378,8 @@ namespace Catch { auto stddev_estimate = stddev_future.get(); #else auto Estimate = [=](double(*f)(double const* , double const*)) { - auto seed = entropy(); + std::random_device rd; + auto seed = rd(); SimplePcg32 rng( seed ); auto resampled = resample(rng, n_resamples, first, last, f); return bootstrap(confidence_level, first, last, resampled, f);