MCPcopy Create free account
hub / github.com/ElementsProject/elements / calcClockResolution

Function calcClockResolution

src/bench/nanobench.h:2037–2049  ·  view source on GitHub ↗

determines resolution of the given clock. This is done by measuring multiple times and returning the minimum time difference.

Source from the content-addressed store, hash-verified

2035
2036// determines resolution of the given clock. This is done by measuring multiple times and returning the minimum time difference.
2037Clock::duration calcClockResolution(size_t numEvaluations) noexcept {
2038 auto bestDuration = Clock::duration::max();
2039 Clock::time_point tBegin;
2040 Clock::time_point tEnd;
2041 for (size_t i = 0; i < numEvaluations; ++i) {
2042 tBegin = Clock::now();
2043 do {
2044 tEnd = Clock::now();
2045 } while (tBegin == tEnd);
2046 bestDuration = (std::min)(bestDuration, tEnd - tBegin);
2047 }
2048 return bestDuration;
2049}
2050
2051// Calculates clock resolution once, and remembers the result
2052Clock::duration clockResolution() noexcept {

Callers 1

clockResolutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected