Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize duration struct members to fix uninitialized data on Windows #78

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions include/nonius/detail/timing.h++
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,22 @@
namespace nonius {
template <typename Duration, typename Result>
struct timing {
Duration elapsed;
Duration elapsed = {};
Result result;
int iterations;
int iterations = 0;

timing() = default;

timing(Duration elapsed, Result result, int iterations)
: elapsed(elapsed)
, result(result)
, iterations(iterations)
{}

template <typename Duration2>
operator timing<Duration2, Result>() const {
return timing<Duration2, Result>{ chrono::duration_cast<Duration2>(elapsed), result, iterations };
}
};
template <typename Clock, typename Sig>
using TimingOf = timing<Duration<Clock>, detail::CompleteType<detail::ResultOf<Sig>>>;
Expand Down
9 changes: 8 additions & 1 deletion include/nonius/environment.h++
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@
namespace nonius {
template <typename Duration>
struct environment_estimate {
Duration mean;
Duration mean = {};
outlier_classification outliers;

environment_estimate() = default;

environment_estimate(Duration mean, outlier_classification outliers)
: mean(mean)
, outliers(outliers)
{}

template <typename Duration2>
operator environment_estimate<Duration2>() const {
return { mean, outliers };
Expand Down
19 changes: 14 additions & 5 deletions include/nonius/estimate.h++
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,23 @@
namespace nonius {
template <typename Duration>
struct estimate {
Duration point;
Duration lower_bound;
Duration upper_bound;
double confidence_interval;
Duration point = {};
Duration lower_bound = {};
Duration upper_bound = {};
double confidence_interval = 0.0;

estimate() = default;

estimate(Duration point, Duration lower_bound, Duration upper_bound, double confidence_interval)
: point(point)
, lower_bound(lower_bound)
, upper_bound(upper_bound)
, confidence_interval(confidence_interval)
{}

template <typename Duration2>
operator estimate<Duration2>() const {
return { point, lower_bound, upper_bound, confidence_interval };
return estimate<Duration2>{ point, lower_bound, upper_bound, confidence_interval };
}
};
} // namespace nonius
Expand Down
21 changes: 16 additions & 5 deletions include/nonius/execution_plan.h++
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@
namespace nonius {
template <typename Duration>
struct execution_plan {
int iterations_per_sample;
Duration estimated_duration;
int iterations_per_sample = 0;
Duration estimated_duration = {};
parameters params;
detail::benchmark_function benchmark;
Duration warmup_time;
int warmup_iterations;
Duration warmup_time = {};
int warmup_iterations = 0;

execution_plan() = default;

execution_plan(int iterations_per_sample, Duration estimated_duration, parameters params, detail::benchmark_function benchmark, Duration warmup_time, int warmup_iterations)
: iterations_per_sample(iterations_per_sample)
, estimated_duration(estimated_duration)
, params(params)
, benchmark(benchmark)
, warmup_time(warmup_time)
, warmup_iterations(warmup_iterations)
{}

template <typename Duration2>
operator execution_plan<Duration2>() const {
return { iterations_per_sample, estimated_duration, params, benchmark, warmup_time, warmup_iterations };
return execution_plan<Duration2>{ iterations_per_sample, estimated_duration, params, benchmark, warmup_time, warmup_iterations };
}

template <typename Clock>
Expand Down