diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 41dcd3d8..37498112 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -86,7 +86,7 @@ int64_t Profiler::GetTime() { #if defined _MSC_VER || defined __CYGWIN__ unsigned int ui; - return int64_t( __rdtscp( &ui ) * s_instance->m_timerMul ); + return int64_t( __rdtscp( &ui ) ); #else return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); #endif @@ -151,6 +151,7 @@ void Profiler::Worker() #else welcome.lz4 = 1; #endif + welcome.timerMul = m_timerMul; welcome.timeBegin = m_timeBegin; welcome.delay = m_delay; @@ -282,6 +283,8 @@ void Profiler::CalibrateTimer() const auto dr = r1 - r0; m_timerMul = double( dt ) / double( dr ); +#else + m_timerMul = 1.; #endif } diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index 8d94541a..b771ee21 100755 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -26,6 +26,7 @@ enum ServerQuery : uint8_t struct WelcomeMessage { uint8_t lz4; + double timerMul; uint64_t timeBegin; uint64_t delay; }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 5524be6c..3c46546f 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -84,8 +84,9 @@ void View::Worker() WelcomeMessage welcome; if( !m_sock.Read( &welcome, sizeof( welcome ), &tv, ShouldExit ) ) goto close; lz4 = welcome.lz4; - m_frames.push_back( welcome.timeBegin ); - m_delay = welcome.delay; + m_timerMul = welcome.timerMul; + m_frames.push_back( welcome.timeBegin * m_timerMul ); + m_delay = welcome.delay * m_timerMul; } m_hasData.store( true, std::memory_order_release ); @@ -232,7 +233,7 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ) CheckString( ev.filename ); CheckString( ev.function ); CheckThreadString( ev.thread ); - zone->start = ev.time; + zone->start = ev.time * m_timerMul; zone->color = ev.color; SourceLocation srcloc { ev.filename, ev.function, ev.line }; @@ -260,8 +261,8 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ) } else { - assert( ev.time <= it->second.time ); - zone->end = it->second.time; + zone->end = it->second.time * m_timerMul; + assert( zone->start <= zone->end ); NewZone( zone, ev.thread ); lock.unlock(); m_pendingEndZone.erase( it ); @@ -279,8 +280,9 @@ void View::ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev ) { auto zone = it->second; std::unique_lock lock( m_lock ); - assert( ev.time >= zone->start ); - zone->end = ev.time; + assert( zone->end == -1 ); + zone->end = ev.time * m_timerMul; + assert( zone->end >= zone->start ); UpdateZone( zone ); lock.unlock(); m_openZones.erase( it ); @@ -291,16 +293,17 @@ void View::ProcessFrameMark( uint64_t id ) { assert( !m_frames.empty() ); const auto lastframe = m_frames.back(); - if( lastframe < id ) + const auto time = id * m_timerMul; + if( lastframe < time ) { std::unique_lock lock( m_lock ); - m_frames.push_back( id ); + m_frames.push_back( time ); } else { - auto it = std::lower_bound( m_frames.begin(), m_frames.end(), id ); + auto it = std::lower_bound( m_frames.begin(), m_frames.end(), time ); std::unique_lock lock( m_lock ); - m_frames.insert( it, id ); + m_frames.insert( it, time ); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 84ea617e..df54a503 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -118,6 +118,7 @@ private: int64_t m_zvEnd; uint64_t m_delay; + double m_timerMul; }; }