mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Remove static instance of std::random_device in Benchmark::analyse_samples
This commit is contained in:
parent
1887d42e3d
commit
a6f22c5169
@ -355,11 +355,6 @@ namespace Catch {
|
|||||||
unsigned int n_resamples,
|
unsigned int n_resamples,
|
||||||
double* first,
|
double* first,
|
||||||
double* last) {
|
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<int>(last - first); // seriously, one can't use integral types without hell in C++
|
auto n = static_cast<int>(last - first); // seriously, one can't use integral types without hell in C++
|
||||||
|
|
||||||
auto mean = &Detail::mean;
|
auto mean = &Detail::mean;
|
||||||
@ -367,7 +362,8 @@ namespace Catch {
|
|||||||
|
|
||||||
#if defined(CATCH_CONFIG_USE_ASYNC)
|
#if defined(CATCH_CONFIG_USE_ASYNC)
|
||||||
auto Estimate = [=](double(*f)(double const*, double const*)) {
|
auto Estimate = [=](double(*f)(double const*, double const*)) {
|
||||||
auto seed = entropy();
|
std::random_device rd;
|
||||||
|
auto seed = rd();
|
||||||
return std::async(std::launch::async, [=] {
|
return std::async(std::launch::async, [=] {
|
||||||
SimplePcg32 rng( seed );
|
SimplePcg32 rng( seed );
|
||||||
auto resampled = resample(rng, n_resamples, first, last, f);
|
auto resampled = resample(rng, n_resamples, first, last, f);
|
||||||
@ -382,7 +378,8 @@ namespace Catch {
|
|||||||
auto stddev_estimate = stddev_future.get();
|
auto stddev_estimate = stddev_future.get();
|
||||||
#else
|
#else
|
||||||
auto Estimate = [=](double(*f)(double const* , double const*)) {
|
auto Estimate = [=](double(*f)(double const* , double const*)) {
|
||||||
auto seed = entropy();
|
std::random_device rd;
|
||||||
|
auto seed = rd();
|
||||||
SimplePcg32 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user