Various improvements to the benchmarking support

* Units from <ratio> are no longer redeclared in our own namespace
* The default clock is `steady_clock`, not `high_resolution_clock`,
because, as HH says "high_resolution_clock is useless. If you want
measure the passing of time, use steady_clock. If you want user
friendly time, use system_clock".
* Benchmarking support is opt-in, not opt-out, to avoid the large
(~10%) compile time penalty.
* Benchmarking-related options in CLI are always present, to decrease
the amount of code that is only compiled conditionally and making
the whole shebang more maintainble.
This commit is contained in:
Martin Hořeňovský 2019-05-19 20:54:44 +02:00
parent ce2560ca95
commit e340ab8db6
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
20 changed files with 54 additions and 65 deletions

View file

@ -16,12 +16,6 @@
namespace Catch {
namespace Benchmark {
template <unsigned Num, unsigned Den = 1>
using ratio = std::ratio<Num, Den>;
using milli = ratio<1, 1000>;
using micro = ratio<1, 1000000>;
using nano = ratio<1, 1000000000>;
template <typename Clock>
using ClockDuration = typename Clock::duration;
template <typename Clock>
@ -30,7 +24,7 @@ namespace Catch {
template <typename Clock>
using TimePoint = typename Clock::time_point;
using default_clock = std::chrono::high_resolution_clock;
using default_clock = std::chrono::steady_clock;
template <typename Clock>
struct now {
@ -39,7 +33,7 @@ namespace Catch {
}
};
using fp_seconds = std::chrono::duration<double, ratio<1>>;
using fp_seconds = std::chrono::duration<double, std::ratio<1>>;
} // namespace Benchmark
} // namespace Catch