Use our PCG32 RNG instead of mt19937 in Benchmark::analyse_samples

This commit is contained in:
Martin Hořeňovský 2023-12-10 21:18:23 +01:00
parent 1774dbfd53
commit 1887d42e3d
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -11,6 +11,7 @@
#include <catch2/internal/catch_compiler_capabilities.hpp> #include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_floating_point_helpers.hpp> #include <catch2/internal/catch_floating_point_helpers.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -368,7 +369,7 @@ namespace Catch {
auto Estimate = [=](double(*f)(double const*, double const*)) { auto Estimate = [=](double(*f)(double const*, double const*)) {
auto seed = entropy(); auto seed = entropy();
return std::async(std::launch::async, [=] { return std::async(std::launch::async, [=] {
std::mt19937 rng(seed); SimplePcg32 rng( seed );
auto resampled = resample(rng, n_resamples, first, last, f); auto resampled = resample(rng, n_resamples, first, last, f);
return bootstrap(confidence_level, first, last, resampled, f); return bootstrap(confidence_level, first, last, resampled, f);
}); });
@ -382,7 +383,7 @@ namespace Catch {
#else #else
auto Estimate = [=](double(*f)(double const* , double const*)) { auto Estimate = [=](double(*f)(double const* , double const*)) {
auto seed = entropy(); auto seed = entropy();
std::mt19937 rng(seed); SimplePcg32 rng( seed );
auto resampled = resample(rng, n_resamples, first, last, f); auto resampled = resample(rng, n_resamples, first, last, f);
return bootstrap(confidence_level, first, last, resampled, f); return bootstrap(confidence_level, first, last, resampled, f);
}; };