mirror of https://github.com/catchorg/Catch2.git
Changed clock resolution estimator to return uint64_t
This commit is contained in:
parent
a9b6813ad9
commit
97d6b08087
|
@ -16,7 +16,7 @@ namespace Catch {
|
||||||
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto estimateClockResolution() -> double {
|
auto estimateClockResolution() -> uint64_t {
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
static const uint64_t iterations = 1000000;
|
static const uint64_t iterations = 1000000;
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ namespace Catch {
|
||||||
|
|
||||||
// We're just taking the mean, here. To do better we could take the std. dev and exclude outliers
|
// We're just taking the mean, here. To do better we could take the std. dev and exclude outliers
|
||||||
// - and potentially do more iterations if there's a high variance.
|
// - and potentially do more iterations if there's a high variance.
|
||||||
return sum/(double)iterations;
|
return sum/iterations;
|
||||||
}
|
}
|
||||||
auto getEstimatedClockResolution() -> double {
|
auto getEstimatedClockResolution() -> uint64_t {
|
||||||
static auto s_resolution = estimateClockResolution();
|
static auto s_resolution = estimateClockResolution();
|
||||||
return s_resolution;
|
return s_resolution;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
auto getCurrentNanosecondsSinceEpoch() -> uint64_t;
|
auto getCurrentNanosecondsSinceEpoch() -> uint64_t;
|
||||||
auto getEstimatedClockResolution() -> double;
|
auto getEstimatedClockResolution() -> uint64_t;
|
||||||
|
|
||||||
class Timer {
|
class Timer {
|
||||||
uint64_t m_nanoseconds = 0;
|
uint64_t m_nanoseconds = 0;
|
||||||
|
|
Loading…
Reference in New Issue