From d55c6a74e1b76b00c3aae104f1eda9361cd36958 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sat, 24 Sep 2016 14:47:39 +1000 Subject: [PATCH 1/5] Explicitly set execution plan durations to zero. --- include/nonius/execution_plan.h++ | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/include/nonius/execution_plan.h++ b/include/nonius/execution_plan.h++ index 5c24197..6a9a79d 100644 --- a/include/nonius/execution_plan.h++ +++ b/include/nonius/execution_plan.h++ @@ -24,16 +24,27 @@ namespace nonius { template struct execution_plan { - int iterations_per_sample; - Duration estimated_duration; + int iterations_per_sample = 0; + Duration estimated_duration = Duration::zero(); parameters params; detail::benchmark_function benchmark; - Duration warmup_time; - int warmup_iterations; + Duration warmup_time = Duration::zero(); + 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 operator execution_plan() const { - return { iterations_per_sample, estimated_duration, params, benchmark, warmup_time, warmup_iterations }; + return execution_plan{ iterations_per_sample, estimated_duration, params, benchmark, warmup_time, warmup_iterations }; } template From 5bc513ecd26b2bc1de88744ff7787efd68250da2 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sat, 24 Sep 2016 14:57:35 +1000 Subject: [PATCH 2/5] Explicity set estimate durations to zero. --- include/nonius/estimate.h++ | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/include/nonius/estimate.h++ b/include/nonius/estimate.h++ index ab4cd65..46b4bb5 100644 --- a/include/nonius/estimate.h++ +++ b/include/nonius/estimate.h++ @@ -17,14 +17,23 @@ namespace nonius { template struct estimate { - Duration point; - Duration lower_bound; - Duration upper_bound; - double confidence_interval; + Duration point = Duration::zero(); + Duration lower_bound = Duration::zero(); + Duration upper_bound = Duration::zero(); + 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 operator estimate() const { - return { point, lower_bound, upper_bound, confidence_interval }; + return estimate{ point, lower_bound, upper_bound, confidence_interval }; } }; } // namespace nonius From cb0449221e653a53abcae9fb95f6d621b97f0ef5 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sat, 24 Sep 2016 15:04:03 +1000 Subject: [PATCH 3/5] Explicitly set environment durations to zero. --- include/nonius/environment.h++ | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/nonius/environment.h++ b/include/nonius/environment.h++ index d92e6d0..241158e 100644 --- a/include/nonius/environment.h++ +++ b/include/nonius/environment.h++ @@ -20,9 +20,16 @@ namespace nonius { template struct environment_estimate { - Duration mean; + Duration mean = Duration::zero(); outlier_classification outliers; + environment_estimate() = default; + + environment_estimate(Duration mean, outlier_classification outliers) + : mean(mean) + , outliers(outliers) + {} + template operator environment_estimate() const { return { mean, outliers }; From e0bfd801becaf3f2bb2a2c296b21f6e7a6d42d8b Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sat, 24 Sep 2016 17:33:08 +1000 Subject: [PATCH 4/5] Explicitly set timing estimate duration to zero. --- include/nonius/detail/timing.h++ | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/nonius/detail/timing.h++ b/include/nonius/detail/timing.h++ index 79557d1..2083a8b 100644 --- a/include/nonius/detail/timing.h++ +++ b/include/nonius/detail/timing.h++ @@ -23,9 +23,22 @@ namespace nonius { template struct timing { - Duration elapsed; + Duration elapsed = Duration::zero(); Result result; - int iterations; + int iterations = 0; + + timing() = default; + + timing(Duration elapsed, Result result, int iterations) + : elapsed(elapsed) + , result(result) + , iterations(iterations) + {} + + template + operator timing() const { + return timing{ chrono::duration_cast(elapsed), result, iterations }; + } }; template using TimingOf = timing, detail::CompleteType>>; From 2c015b70ab3650e36f8c898fffd1f11fc10dc395 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sat, 24 Sep 2016 22:46:36 +1000 Subject: [PATCH 5/5] Switched to {} initialization for Duration to fix msvc compile errors. --- include/nonius/detail/timing.h++ | 2 +- include/nonius/environment.h++ | 2 +- include/nonius/estimate.h++ | 6 +++--- include/nonius/execution_plan.h++ | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/nonius/detail/timing.h++ b/include/nonius/detail/timing.h++ index 2083a8b..12c1b91 100644 --- a/include/nonius/detail/timing.h++ +++ b/include/nonius/detail/timing.h++ @@ -23,7 +23,7 @@ namespace nonius { template struct timing { - Duration elapsed = Duration::zero(); + Duration elapsed = {}; Result result; int iterations = 0; diff --git a/include/nonius/environment.h++ b/include/nonius/environment.h++ index 241158e..4c5acb4 100644 --- a/include/nonius/environment.h++ +++ b/include/nonius/environment.h++ @@ -20,7 +20,7 @@ namespace nonius { template struct environment_estimate { - Duration mean = Duration::zero(); + Duration mean = {}; outlier_classification outliers; environment_estimate() = default; diff --git a/include/nonius/estimate.h++ b/include/nonius/estimate.h++ index 46b4bb5..290df42 100644 --- a/include/nonius/estimate.h++ +++ b/include/nonius/estimate.h++ @@ -17,9 +17,9 @@ namespace nonius { template struct estimate { - Duration point = Duration::zero(); - Duration lower_bound = Duration::zero(); - Duration upper_bound = Duration::zero(); + Duration point = {}; + Duration lower_bound = {}; + Duration upper_bound = {}; double confidence_interval = 0.0; estimate() = default; diff --git a/include/nonius/execution_plan.h++ b/include/nonius/execution_plan.h++ index 6a9a79d..9c63aae 100644 --- a/include/nonius/execution_plan.h++ +++ b/include/nonius/execution_plan.h++ @@ -25,10 +25,10 @@ namespace nonius { template struct execution_plan { int iterations_per_sample = 0; - Duration estimated_duration = Duration::zero(); + Duration estimated_duration = {}; parameters params; detail::benchmark_function benchmark; - Duration warmup_time = Duration::zero(); + Duration warmup_time = {}; int warmup_iterations = 0; execution_plan() = default;