Skip to content

Commit

Permalink
Make Clock propagate correctly across functions.
Browse files Browse the repository at this point in the history
Now only nonius::go has a defaulted Clock parameter. This addresses libnonius#74
by fixing the test, but it doesn't address the underlying problem that
occurs with the default_clock.
  • Loading branch information
rmartinho committed Sep 14, 2016
1 parent a7f060b commit ddddadf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/nonius/detail/measure.h++
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace nonius {
namespace detail {
template <typename Clock = default_clock, typename Fun, typename... Args>
template <typename Clock, typename Fun, typename... Args>
TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) {
auto start = Clock::now();
auto&& r = detail::complete_invoke(fun, std::forward<Args>(args)...);
Expand Down
2 changes: 1 addition & 1 deletion include/nonius/detail/run_for_at_least.h++
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace nonius {
}
};

template <typename Clock = default_clock, typename Fun>
template <typename Clock, typename Fun>
TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(const parameters& params, Duration<Clock> how_long, int seed, Fun&& fun) {
auto iters = seed;
while(iters < (1 << 30)) {
Expand Down
2 changes: 1 addition & 1 deletion include/nonius/environment.h++
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace nonius {
return { mean, outliers };
}
};
template <typename Clock = default_clock>
template <typename Clock>
struct environment {
using clock_type = Clock;
environment_estimate<FloatDuration<Clock>> clock_resolution;
Expand Down
6 changes: 3 additions & 3 deletions include/nonius/go.h++
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace nonius {
}
template <typename Clock = default_clock, typename Iterator>
void go(configuration cfg, Iterator first, Iterator last, reporter&& rep) {
go(cfg, first, last, rep);
go<Clock>(cfg, first, last, rep);
}
struct no_such_reporter : virtual std::exception {
char const* what() const NONIUS_NOEXCEPT override {
Expand All @@ -170,8 +170,8 @@ namespace nonius {
void go(configuration cfg, benchmark_registry& benchmarks = global_benchmark_registry(), reporter_registry& reporters = global_reporter_registry()) {
auto it = reporters.find(cfg.reporter);
if(it == reporters.end()) throw no_such_reporter();
validate_benchmarks(benchmarks.begin(), benchmarks.end());
go(cfg, benchmarks.begin(), benchmarks.end(), *it->second);
validate_benchmarks<Clock>(benchmarks.begin(), benchmarks.end());
go<Clock>(cfg, benchmarks.begin(), benchmarks.end(), *it->second);
}
} // namespace nonius

Expand Down

0 comments on commit ddddadf

Please sign in to comment.