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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-09-29 11:24:14 +0200
committerMartin Hořeňovský2021-09-29 11:24:18 +0200
commit5250cf6d580fd85643aa2f6008f3f1adb7dda03e (patch)
treedff94ad19e3e956779695aa47f1ce49ebf8174c8
parent426954032f263754d2fff4cffce8552e7371965e (diff)
downloadcatch3-5250cf6d580fd85643aa2f6008f3f1adb7dda03e.tar.gz
Remove getEstimatedClockResolution from Timer
It used to be part of the experimental benchmarking support, but since that was replaced with proper benchmarking support with its own timer facilities, it is now a dead code and useless.
-rw-r--r--src/catch2/catch_timer.cpp36
-rw-r--r--src/catch2/catch_timer.hpp1
2 files changed, 0 insertions, 37 deletions
diff --git a/src/catch2/catch_timer.cpp b/src/catch2/catch_timer.cpp
index 659292dd..8084352e 100644
--- a/src/catch2/catch_timer.cpp
+++ b/src/catch2/catch_timer.cpp
@@ -17,42 +17,6 @@ namespace Catch {
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
}
- namespace {
- auto estimateClockResolution() -> uint64_t {
- uint64_t sum = 0;
- static const uint64_t iterations = 1000000;
-
- auto startTime = getCurrentNanosecondsSinceEpoch();
-
- for( std::size_t i = 0; i < iterations; ++i ) {
-
- uint64_t ticks;
- uint64_t baseTicks = getCurrentNanosecondsSinceEpoch();
- do {
- ticks = getCurrentNanosecondsSinceEpoch();
- } while( ticks == baseTicks );
-
- auto delta = ticks - baseTicks;
- sum += delta;
-
- // If we have been calibrating for over 3 seconds -- the clock
- // is terrible and we should move on.
- // TBD: How to signal that the measured resolution is probably wrong?
- if (ticks > startTime + 3 * nanosecondsInSecond) {
- return sum / ( i + 1u );
- }
- }
-
- // 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.
- return sum/iterations;
- }
- }
- auto getEstimatedClockResolution() -> uint64_t {
- static auto s_resolution = estimateClockResolution();
- return s_resolution;
- }
-
void Timer::start() {
m_nanoseconds = getCurrentNanosecondsSinceEpoch();
}
diff --git a/src/catch2/catch_timer.hpp b/src/catch2/catch_timer.hpp
index 03bbf497..66aab87b 100644
--- a/src/catch2/catch_timer.hpp
+++ b/src/catch2/catch_timer.hpp
@@ -13,7 +13,6 @@
namespace Catch {
auto getCurrentNanosecondsSinceEpoch() -> uint64_t;
- auto getEstimatedClockResolution() -> uint64_t;
class Timer {
uint64_t m_nanoseconds = 0;