Calculate timer resolution.

This commit is contained in:
Bartosz Taudul 2017-09-29 18:29:39 +02:00
parent 445d2831ed
commit 6a2cb2c14e
2 changed files with 12 additions and 0 deletions

View File

@ -358,6 +358,17 @@ void Profiler::CalibrateDelay()
const auto df = t0 - f0; const auto df = t0 - f0;
m_delay = ( dt - df ) / Events; m_delay = ( dt - df ) / Events;
uint64_t mindiff = std::numeric_limits<uint64_t>::max();
for( int i=0; i<Iterations * 10; i++ )
{
const auto t0 = GetTime();
const auto t1 = GetTime();
const auto dt = t1 - t0;
if( dt > 0 && dt < mindiff ) mindiff = dt;
}
m_resolution = mindiff;
enum { Bulk = 1000 }; enum { Bulk = 1000 };
moodycamel::ConsumerToken token( s_queue ); moodycamel::ConsumerToken token( s_queue );
int left = Events * 2; int left = Events * 2;

View File

@ -63,6 +63,7 @@ private:
void CalibrateDelay(); void CalibrateDelay();
double m_timerMul; double m_timerMul;
uint64_t m_resolution;
uint64_t m_delay; uint64_t m_delay;
int64_t m_timeBegin; int64_t m_timeBegin;
uint64_t m_mainThread; uint64_t m_mainThread;