Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-08-31 21:52:08 +0200
committerMartin Hořeňovský2023-09-08 10:04:31 +0200
commit47a2c969380259e899f471edde84f06a6d687dc9 (patch)
tree28bfe7778e7a4e278f2ba093a7928301f5e3760d /src
parentfb96279aedc7472326189823078299abb2dad9a4 (diff)
downloadcatch3-47a2c969380259e899f471edde84f06a6d687dc9.tar.gz
Reduce the number of templates in Benchmarking
The basic idea was to reduce the number of things dependent on the `Clock` type. To that end, I replaced `Duration<Clock>` with `IDuration` typedef for `std::nanoseconds`, and `FloatDuration<Clock>` with `FDuration` typedef for `Duration<double, std::nano>`. We can generally assume that any clock's duration can be expressed in nanoseconds, as long as we insert `duration_cast`s into the right places. Note that we cannot remove all dependence on `Clock` as a template arguments, because functions that actually measure the elapsed time have to use the Clock. We also changed some template function arguments to pass plain function pointers, so that the actual implementation can be placed into a cpp file.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/catch2/benchmark/catch_benchmark.hpp12
-rw-r--r--src/catch2/benchmark/catch_chronometer.hpp5
-rw-r--r--src/catch2/benchmark/catch_clock.hpp16
-rw-r--r--src/catch2/benchmark/catch_environment.hpp13
-rw-r--r--src/catch2/benchmark/catch_estimate.hpp13
-rw-r--r--src/catch2/benchmark/catch_execution_plan.hpp24
-rw-r--r--src/catch2/benchmark/catch_sample_analysis.hpp25
-rw-r--r--src/catch2/benchmark/detail/catch_analyse.cpp85
-rw-r--r--src/catch2/benchmark/detail/catch_analyse.hpp68
-rw-r--r--src/catch2/benchmark/detail/catch_benchmark_stats.hpp28
-rw-r--r--src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp4
-rw-r--r--src/catch2/benchmark/detail/catch_estimate_clock.hpp22
-rw-r--r--src/catch2/benchmark/detail/catch_measure.hpp2
-rw-r--r--src/catch2/benchmark/detail/catch_run_for_at_least.hpp8
-rw-r--r--src/catch2/benchmark/detail/catch_stats.cpp81
-rw-r--r--src/catch2/benchmark/detail/catch_stats.hpp79
-rw-r--r--src/catch2/benchmark/detail/catch_timing.hpp8
-rw-r--r--src/catch2/meson.build1
19 files changed, 246 insertions, 249 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0fdf931e..4e3b3566 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,6 +33,7 @@ set(BENCHMARK_HEADERS
)
set(BENCHMARK_SOURCES
${SOURCES_DIR}/benchmark/catch_chronometer.cpp
+ ${SOURCES_DIR}/benchmark/detail/catch_analyse.cpp
${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp
${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp
${SOURCES_DIR}/benchmark/detail/catch_stats.cpp
diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp
index ea8ffa75..3db40bb0 100644
--- a/src/catch2/benchmark/catch_benchmark.hpp
+++ b/src/catch2/benchmark/catch_benchmark.hpp
@@ -45,16 +45,18 @@ namespace Catch {
: fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {}
template <typename Clock>
- ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {
+ ExecutionPlan prepare(const IConfig &cfg, Environment env) const {
auto min_time = env.clock_resolution.mean * Detail::minimum_ticks;
auto run_time = std::max(min_time, std::chrono::duration_cast<decltype(min_time)>(cfg.benchmarkWarmupTime()));
- auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(run_time), 1, fun);
+ auto&& test = Detail::run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(run_time), 1, fun);
int new_iters = static_cast<int>(std::ceil(min_time * test.iterations / test.elapsed));
- return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FloatDuration<Clock>>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations };
+ return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast<FDuration>(cfg.benchmarkWarmupTime()), Detail::warmup_iterations };
}
template <typename Clock = default_clock>
void run() {
+ static_assert( Clock::is_steady,
+ "Benchmarking clock should be steady" );
auto const* cfg = getCurrentContext().getConfig();
auto env = Detail::measure_environment<Clock>();
@@ -81,8 +83,8 @@ namespace Catch {
return plan.template run<Clock>(*cfg, env);
});
- auto analysis = Detail::analyse(*cfg, env, samples.begin(), samples.end());
- BenchmarkStats<FloatDuration<Clock>> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
+ auto analysis = Detail::analyse(*cfg, samples.data(), samples.data() + samples.size());
+ BenchmarkStats<> stats{ CATCH_MOVE(info), CATCH_MOVE(analysis.samples), analysis.mean, analysis.standard_deviation, analysis.outliers, analysis.outlier_variance };
getResultCapture().benchmarkEnded(stats);
} CATCH_CATCH_ANON (TestFailureException const&) {
getResultCapture().benchmarkFailed("Benchmark failed due to failed assertion"_sr);
diff --git a/src/catch2/benchmark/catch_chronometer.hpp b/src/catch2/benchmark/catch_chronometer.hpp
index c3f81306..95498e6b 100644
--- a/src/catch2/benchmark/catch_chronometer.hpp
+++ b/src/catch2/benchmark/catch_chronometer.hpp
@@ -32,7 +32,10 @@ namespace Catch {
void start() override { started = Clock::now(); }
void finish() override { finished = Clock::now(); }
- ClockDuration<Clock> elapsed() const { return finished - started; }
+ IDuration elapsed() const {
+ return std::chrono::duration_cast<std::chrono::nanoseconds>(
+ finished - started );
+ }
TimePoint<Clock> started;
TimePoint<Clock> finished;
diff --git a/src/catch2/benchmark/catch_clock.hpp b/src/catch2/benchmark/catch_clock.hpp
index cee46097..4068c4d2 100644
--- a/src/catch2/benchmark/catch_clock.hpp
+++ b/src/catch2/benchmark/catch_clock.hpp
@@ -11,28 +11,16 @@
#define CATCH_CLOCK_HPP_INCLUDED
#include <chrono>
-#include <ratio>
namespace Catch {
namespace Benchmark {
- template <typename Clock>
- using ClockDuration = typename Clock::duration;
- template <typename Clock>
- using FloatDuration = std::chrono::duration<double, typename Clock::period>;
+ using IDuration = std::chrono::nanoseconds;
+ using FDuration = std::chrono::duration<double, std::nano>;
template <typename Clock>
using TimePoint = typename Clock::time_point;
using default_clock = std::chrono::steady_clock;
-
- template <typename Clock>
- struct now {
- TimePoint<Clock> operator()() const {
- return Clock::now();
- }
- };
-
- using fp_seconds = std::chrono::duration<double, std::ratio<1>>;
} // namespace Benchmark
} // namespace Catch
diff --git a/src/catch2/benchmark/catch_environment.hpp b/src/catch2/benchmark/catch_environment.hpp
index 5d3816a5..da3f2fa9 100644
--- a/src/catch2/benchmark/catch_environment.hpp
+++ b/src/catch2/benchmark/catch_environment.hpp
@@ -15,20 +15,13 @@
namespace Catch {
namespace Benchmark {
- template <typename Duration>
struct EnvironmentEstimate {
- Duration mean;
+ FDuration mean;
OutlierClassification outliers;
-
- template <typename Duration2>
- operator EnvironmentEstimate<Duration2>() const {
- return { mean, outliers };
- }
};
- template <typename Clock>
struct Environment {
- EnvironmentEstimate<FloatDuration<Clock>> clock_resolution;
- EnvironmentEstimate<FloatDuration<Clock>> clock_cost;
+ EnvironmentEstimate clock_resolution;
+ EnvironmentEstimate clock_cost;
};
} // namespace Benchmark
} // namespace Catch
diff --git a/src/catch2/benchmark/catch_estimate.hpp b/src/catch2/benchmark/catch_estimate.hpp
index be594a18..64383a2e 100644
--- a/src/catch2/benchmark/catch_estimate.hpp
+++ b/src/catch2/benchmark/catch_estimate.hpp
@@ -12,17 +12,12 @@
namespace Catch {
namespace Benchmark {
- template <typename Duration>
+ template <typename Type>
struct Estimate {
- Duration point;
- Duration lower_bound;
- Duration upper_bound;
+ Type point;
+ Type lower_bound;
+ Type upper_bound;
double confidence_interval;
-
- template <typename Duration2>
- operator Estimate<Duration2>() const {
- return { point, lower_bound, upper_bound, confidence_interval };
- }
};
} // namespace Benchmark
} // namespace Catch
diff --git a/src/catch2/benchmark/catch_execution_plan.hpp b/src/catch2/benchmark/catch_execution_plan.hpp
index 4f60a646..17ca589f 100644
--- a/src/catch2/benchmark/catch_execution_plan.hpp
+++ b/src/catch2/benchmark/catch_execution_plan.hpp
@@ -21,33 +21,31 @@
namespace Catch {
namespace Benchmark {
- template <typename Duration>
struct ExecutionPlan {
int iterations_per_sample;
- Duration estimated_duration;
+ FDuration estimated_duration;
Detail::BenchmarkFunction benchmark;
- Duration warmup_time;
+ FDuration warmup_time;
int warmup_iterations;
- template <typename Duration2>
- operator ExecutionPlan<Duration2>() const {
- return { iterations_per_sample, estimated_duration, benchmark, warmup_time, warmup_iterations };
- }
-
template <typename Clock>
- std::vector<FloatDuration<Clock>> run(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {
+ std::vector<FDuration> run(const IConfig &cfg, Environment env) const {
// warmup a bit
- Detail::run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_iterations, Detail::repeat(now<Clock>{}));
+ Detail::run_for_at_least<Clock>(
+ std::chrono::duration_cast<IDuration>( warmup_time ),
+ warmup_iterations,
+ Detail::repeat( []() { return Clock::now(); } )
+ );
- std::vector<FloatDuration<Clock>> times;
+ std::vector<FDuration> times;
const auto num_samples = cfg.benchmarkSamples();
times.reserve( num_samples );
for ( size_t i = 0; i < num_samples; ++i ) {
Detail::ChronometerModel<Clock> model;
this->benchmark( Chronometer( model, iterations_per_sample ) );
auto sample_time = model.elapsed() - env.clock_cost.mean;
- if ( sample_time < FloatDuration<Clock>::zero() ) {
- sample_time = FloatDuration<Clock>::zero();
+ if ( sample_time < FDuration::zero() ) {
+ sample_time = FDuration::zero();
}
times.push_back(sample_time / iterations_per_sample);
}
diff --git a/src/catch2/benchmark/catch_sample_analysis.hpp b/src/catch2/benchmark/catch_sample_analysis.hpp
index 97b8fe50..aeb87d05 100644
--- a/src/catch2/benchmark/catch_sample_analysis.hpp
+++ b/src/catch2/benchmark/catch_sample_analysis.hpp
@@ -12,35 +12,18 @@
#include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp>
-#include <catch2/internal/catch_move_and_forward.hpp>
+#include <catch2/benchmark/catch_clock.hpp>
#include <vector>
namespace Catch {
namespace Benchmark {
- template <typename Duration>
struct SampleAnalysis {
- std::vector<Duration> samples;
- Estimate<Duration> mean;
- Estimate<Duration> standard_deviation;
+ std::vector<FDuration> samples;
+ Estimate<FDuration> mean;
+ Estimate<FDuration> standard_deviation;
OutlierClassification outliers;
double outlier_variance;
-
- template <typename Duration2>
- operator SampleAnalysis<Duration2>() const {
- std::vector<Duration2> samples2;
- samples2.reserve(samples.size());
- for (auto const& d : samples) {
- samples2.push_back(Duration2(d));
- }
- return {
- CATCH_MOVE(samples2),
- mean,
- standard_deviation,
- outliers,
- outlier_variance,
- };
- }
};
} // namespace Benchmark
} // namespace Catch
diff --git a/src/catch2/benchmark/detail/catch_analyse.cpp b/src/catch2/benchmark/detail/catch_analyse.cpp
new file mode 100644
index 00000000..7d27daf1
--- /dev/null
+++ b/src/catch2/benchmark/detail/catch_analyse.cpp
@@ -0,0 +1,85 @@
+
+// Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.txt or copy at
+// https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+// Adapted from donated nonius code.
+
+#include <catch2/benchmark/detail/catch_analyse.hpp>
+#include <catch2/benchmark/catch_clock.hpp>
+#include <catch2/benchmark/catch_sample_analysis.hpp>
+#include <catch2/benchmark/detail/catch_stats.hpp>
+#include <catch2/interfaces/catch_interfaces_config.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
+
+#include <vector>
+
+namespace Catch {
+ namespace Benchmark {
+ namespace Detail {
+ SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last) {
+ if (!cfg.benchmarkNoAnalysis()) {
+ std::vector<double> samples;
+ samples.reserve(static_cast<size_t>(last - first));
+ for (auto current = first; current != last; ++current) {
+ samples.push_back( current->count() );
+ }
+
+ auto analysis = Catch::Benchmark::Detail::analyse_samples(
+ cfg.benchmarkConfidenceInterval(),
+ cfg.benchmarkResamples(),
+ samples.data(),
+ samples.data() + samples.size() );
+ auto outliers = Catch::Benchmark::Detail::classify_outliers(
+ samples.data(), samples.data() + samples.size() );
+
+ auto wrap_estimate = [](Estimate<double> e) {
+ return Estimate<FDuration> {
+ FDuration(e.point),
+ FDuration(e.lower_bound),
+ FDuration(e.upper_bound),
+ e.confidence_interval,
+ };
+ };
+ std::vector<FDuration> samples2;
+ samples2.reserve(samples.size());
+ for (auto s : samples) {
+ samples2.push_back( FDuration( s ) );
+ }
+
+ return {
+ CATCH_MOVE(samples2),
+ wrap_estimate(analysis.mean),
+ wrap_estimate(analysis.standard_deviation),
+ outliers,
+ analysis.outlier_variance,
+ };
+ } else {
+ std::vector<FDuration> samples;
+ samples.reserve(static_cast<size_t>(last - first));
+
+ FDuration mean = FDuration(0);
+ int i = 0;
+ for (auto it = first; it < last; ++it, ++i) {
+ samples.push_back(FDuration(*it));
+ mean += FDuration(*it);
+ }
+ mean /= i;
+
+ return SampleAnalysis{
+ CATCH_MOVE(samples),
+ Estimate<FDuration>{ mean, mean, mean, 0.0 },
+ Estimate<FDuration>{ FDuration( 0 ),
+ FDuration( 0 ),
+ FDuration( 0 ),
+ 0.0 },
+ OutlierClassification{},
+ 0.0
+ };
+ }
+ }
+ } // namespace Detail
+ } // namespace Benchmark
+} // namespace Catch
diff --git a/src/catch2/benchmark/detail/catch_analyse.hpp b/src/catch2/benchmark/detail/catch_analyse.hpp
index 60db7d87..5e3f7b0f 100644
--- a/src/catch2/benchmark/detail/catch_analyse.hpp
+++ b/src/catch2/benchmark/detail/catch_analyse.hpp
@@ -10,76 +10,16 @@
#ifndef CATCH_ANALYSE_HPP_INCLUDED
#define CATCH_ANALYSE_HPP_INCLUDED
-#include <catch2/benchmark/catch_environment.hpp>
+#include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/catch_sample_analysis.hpp>
-#include <catch2/benchmark/detail/catch_stats.hpp>
-#include <catch2/interfaces/catch_interfaces_config.hpp>
-#include <catch2/internal/catch_move_and_forward.hpp>
-#include <vector>
namespace Catch {
+ class IConfig;
+
namespace Benchmark {
namespace Detail {
- template <typename Duration, typename Iterator>
- SampleAnalysis<Duration> analyse(const IConfig &cfg, Environment<Duration>, Iterator first, Iterator last) {
- if (!cfg.benchmarkNoAnalysis()) {
- std::vector<double> samples;
- samples.reserve(static_cast<size_t>(last - first));
- for (auto current = first; current != last; ++current) {
- samples.push_back( current->count() );
- }
-
- auto analysis = Catch::Benchmark::Detail::analyse_samples(
- cfg.benchmarkConfidenceInterval(),
- cfg.benchmarkResamples(),
- samples.data(),
- samples.data() + samples.size() );
- auto outliers = Catch::Benchmark::Detail::classify_outliers(
- samples.data(), samples.data() + samples.size() );
-
- auto wrap_estimate = [](Estimate<double> e) {
- return Estimate<Duration> {
- Duration(e.point),
- Duration(e.lower_bound),
- Duration(e.upper_bound),
- e.confidence_interval,
- };
- };
- std::vector<Duration> samples2;
- samples2.reserve(samples.size());
- for (auto s : samples) {
- samples2.push_back( Duration( s ) );
- }
-
- return {
- CATCH_MOVE(samples2),
- wrap_estimate(analysis.mean),
- wrap_estimate(analysis.standard_deviation),
- outliers,
- analysis.outlier_variance,
- };
- } else {
- std::vector<Duration> samples;
- samples.reserve(static_cast<size_t>(last - first));
-
- Duration mean = Duration(0);
- int i = 0;
- for (auto it = first; it < last; ++it, ++i) {
- samples.push_back(Duration(*it));
- mean += Duration(*it);
- }
- mean /= i;
-
- return {
- CATCH_MOVE(samples),
- Estimate<Duration>{mean, mean, mean, 0.0},
- Estimate<Duration>{Duration(0), Duration(0), Duration(0), 0.0},
- OutlierClassification{},
- 0.0
- };
- }
- }
+ SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last);
} // namespace Detail
} // namespace Benchmark
} // namespace Catch
diff --git a/src/catch2/benchmark/detail/catch_benchmark_stats.hpp b/src/catch2/benchmark/detail/catch_benchmark_stats.hpp
index a8b3494e..3633bc9f 100644
--- a/src/catch2/benchmark/detail/catch_benchmark_stats.hpp
+++ b/src/catch2/benchmark/detail/catch_benchmark_stats.hpp
@@ -8,7 +8,6 @@
#ifndef CATCH_BENCHMARK_STATS_HPP_INCLUDED
#define CATCH_BENCHMARK_STATS_HPP_INCLUDED
-#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/benchmark/catch_estimate.hpp>
#include <catch2/benchmark/catch_outlier_classification.hpp>
// The fwd decl & default specialization needs to be seen by VS2017 before
@@ -30,32 +29,17 @@ namespace Catch {
double clockCost;
};
- template <class Duration>
+ // We need to keep template parameter for backwards compatibility,
+ // but we also do not want to use the template paraneter.
+ template <class Dummy>
struct BenchmarkStats {
BenchmarkInfo info;
- std::vector<Duration> samples;
- Benchmark::Estimate<Duration> mean;
- Benchmark::Estimate<Duration> standardDeviation;
+ std::vector<Benchmark::FDuration> samples;
+ Benchmark::Estimate<Benchmark::FDuration> mean;
+ Benchmark::Estimate<Benchmark::FDuration> standardDeviation;
Benchmark::OutlierClassification outliers;
double outlierVariance;
-
- template <typename Duration2>
- operator BenchmarkStats<Duration2>() const {
- std::vector<Duration2> samples2;
- samples2.reserve(samples.size());
- for (auto const& sample : samples) {
- samples2.push_back(Duration2(sample));
- }
- return {
- info,
- CATCH_MOVE(samples2),
- mean,
- standardDeviation,
- outliers,
- outlierVariance,
- };
- }
};
diff --git a/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp b/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp
index 60772561..2ccc25d5 100644
--- a/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp
+++ b/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp
@@ -8,14 +8,14 @@
#ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
#define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED
-#include <chrono>
+#include <catch2/benchmark/catch_clock.hpp>
namespace Catch {
// We cannot forward declare the type with default template argument
// multiple times, so it is split out into a separate header so that
// we can prevent multiple declarations in dependees
- template <typename Duration = std::chrono::duration<double, std::nano>>
+ template <typename Duration = Benchmark::FDuration>
struct BenchmarkStats;
} // end namespace Catch
diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
index a0dc2d3d..918484a9 100644
--- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp
+++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp
@@ -55,23 +55,23 @@ namespace Catch {
template <typename Clock>
int warmup() {
- return run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(warmup_time), warmup_seed, &resolution<Clock>)
+ return run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(warmup_time), warmup_seed, &resolution<Clock>)
.iterations;
}
template <typename Clock>
- EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_resolution(int iterations) {
- auto r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_resolution_estimation_time), iterations, &resolution<Clock>)
+ EnvironmentEstimate estimate_clock_resolution(int iterations) {
+ auto r = run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(clock_resolution_estimation_time), iterations, &resolution<Clock>)
.result;
return {
- FloatDuration<Clock>(mean(r.data(), r.data() + r.size())),
+ FDuration(mean(r.data(), r.data() + r.size())),
classify_outliers(r.data(), r.data() + r.size()),
};
}
template <typename Clock>
- EnvironmentEstimate<FloatDuration<Clock>> estimate_clock_cost(FloatDuration<Clock> resolution) {
+ EnvironmentEstimate estimate_clock_cost(FDuration resolution) {
auto time_limit = (std::min)(
resolution * clock_cost_estimation_tick_limit,
- FloatDuration<Clock>(clock_cost_estimation_time_limit));
+ FDuration(clock_cost_estimation_time_limit));
auto time_clock = [](int k) {
return Detail::measure<Clock>([k] {
for (int i = 0; i < k; ++i) {
@@ -82,7 +82,7 @@ namespace Catch {
};
time_clock(1);
int iters = clock_cost_estimation_iterations;
- auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<ClockDuration<Clock>>(clock_cost_estimation_time), iters, time_clock);
+ auto&& r = run_for_at_least<Clock>(std::chrono::duration_cast<IDuration>(clock_cost_estimation_time), iters, time_clock);
std::vector<double> times;
int nsamples = static_cast<int>(std::ceil(time_limit / r.elapsed));
times.reserve(static_cast<size_t>(nsamples));
@@ -92,18 +92,18 @@ namespace Catch {
.count() ) );
}
return {
- FloatDuration<Clock>(mean(times.data(), times.data() + times.size())),
+ FDuration(mean(times.data(), times.data() + times.size())),
classify_outliers(times.data(), times.data() + times.size()),
};
}
template <typename Clock>
- Environment<FloatDuration<Clock>> measure_environment() {
+ Environment measure_environment() {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wexit-time-destructors"
#endif
- static Catch::Detail::unique_ptr<Environment<FloatDuration<Clock>>> env;
+ static Catch::Detail::unique_ptr<Environment> env;
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
@@ -115,7 +115,7 @@ namespace Catch {
auto resolution = Detail::estimate_clock_resolution<Clock>(iters);
auto cost = Detail::estimate_clock_cost<Clock>(resolution.mean);
- env = Catch::Detail::make_unique<Environment<FloatDuration<Clock>>>( Environment<FloatDuration<Clock>>{resolution, cost} );
+ env = Catch::Detail::make_unique<Environment>( Environment{resolution, cost} );
return *env;
}
} // namespace Detail
diff --git a/src/catch2/benchmark/detail/catch_measure.hpp b/src/catch2/benchmark/detail/catch_measure.hpp
index 1a30efab..37494a68 100644
--- a/src/catch2/benchmark/detail/catch_measure.hpp
+++ b/src/catch2/benchmark/detail/catch_measure.hpp
@@ -18,7 +18,7 @@ namespace Catch {
namespace Benchmark {
namespace Detail {
template <typename Clock, typename Fun, typename... Args>
- TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) {
+ TimingOf<Fun, Args...> measure(Fun&& fun, Args&&... args) {
auto start = Clock::now();
auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...);
auto end = Clock::now();
diff --git a/src/catch2/benchmark/detail/catch_run_for_at_least.hpp b/src/catch2/benchmark/detail/catch_run_for_at_least.hpp
index 976a4b24..4dfa8bbb 100644
--- a/src/catch2/benchmark/detail/catch_run_for_at_least.hpp
+++ b/src/catch2/benchmark/detail/catch_run_for_at_least.hpp
@@ -24,11 +24,11 @@ namespace Catch {
namespace Benchmark {
namespace Detail {
template <typename Clock, typename Fun>
- TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) {
+ TimingOf<Fun, int> measure_one(Fun&& fun, int iters, std::false_type) {
return Detail::measure<Clock>(fun, iters);
}
template <typename Clock, typename Fun>
- TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) {
+ TimingOf<Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) {
Detail::ChronometerModel<Clock> meter;
auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters));
@@ -43,8 +43,8 @@ namespace Catch {
void throw_optimized_away_error();
template <typename Clock, typename Fun>
- TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>>
- run_for_at_least(ClockDuration<Clock> how_long,
+ TimingOf<Fun, run_for_at_least_argument_t<Clock, Fun>>
+ run_for_at_least(IDuration how_long,
const int initial_iterations,
Fun&& fun) {
auto iters = initial_iterations;
diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src