More precise profiler init end time measurement.

This commit is contained in:
Bartosz Taudul 2017-10-17 01:07:54 +02:00
parent 0ed789825a
commit 51f5ae4796
2 changed files with 8 additions and 4 deletions

View File

@ -102,7 +102,8 @@ static Profiler init_order(104) s_profiler;
Profiler::Profiler()
: m_mainThread( GetThreadHandle() )
: m_timeBegin( 0 )
, m_mainThread( GetThreadHandle() )
, m_epoch( std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count() )
, m_shutdown( false )
, m_stream( LZ4_createStream() )
@ -120,12 +121,13 @@ Profiler::Profiler()
CalibrateTimer();
CalibrateDelay();
uint32_t cpu;
m_timeBegin = GetTime( cpu );
s_thread = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_thread) Thread( LaunchWorker, this );
SetThreadName( s_thread->Handle(), "Tracy Profiler" );
uint32_t cpu;
m_timeBegin.store( GetTime( cpu ), std::memory_order_relaxed );
}
Profiler::~Profiler()
@ -155,6 +157,8 @@ void Profiler::Worker()
ListenSocket listen;
listen.Listen( "8086", 8 );
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
for(;;)
{
for(;;)

View File

@ -177,7 +177,7 @@ private:
double m_timerMul;
uint64_t m_resolution;
uint64_t m_delay;
int64_t m_timeBegin;
std::atomic<int64_t> m_timeBegin;
uint64_t m_mainThread;
uint64_t m_epoch;
std::atomic<bool> m_shutdown;