mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Cache context switch data queries.
This commit is contained in:
parent
cf4e04440e
commit
9a364fe5fe
@ -1318,11 +1318,13 @@ uint64_t Worker::GetContextSwitchCount() const
|
||||
return cnt;
|
||||
}
|
||||
|
||||
const ContextSwitch* const Worker::GetContextSwitchData( uint64_t thread ) const
|
||||
const ContextSwitch* const Worker::GetContextSwitchDataImpl( uint64_t thread )
|
||||
{
|
||||
auto it = m_data.ctxSwitch.find( thread );
|
||||
if( it != m_data.ctxSwitch.end() )
|
||||
{
|
||||
m_data.ctxSwitchLast.first = thread;
|
||||
m_data.ctxSwitchLast.second = it->second;
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
|
@ -145,7 +145,14 @@ private:
|
||||
|
||||
struct DataBlock
|
||||
{
|
||||
DataBlock() : zonesCnt( 0 ), lastTime( 0 ), frameOffset( 0 ), threadLast( std::numeric_limits<uint64_t>::max(), 0 ), threadDataLast( std::numeric_limits<uint64_t>::max(), nullptr ) {}
|
||||
DataBlock()
|
||||
: zonesCnt( 0 )
|
||||
, lastTime( 0 )
|
||||
, frameOffset( 0 )
|
||||
, threadLast( std::numeric_limits<uint64_t>::max(), 0 )
|
||||
, threadDataLast( std::numeric_limits<uint64_t>::max(), nullptr )
|
||||
, ctxSwitchLast( std::numeric_limits<uint64_t>::max(), nullptr )
|
||||
{}
|
||||
|
||||
std::shared_mutex lock;
|
||||
StringDiscovery<FrameData*> frames;
|
||||
@ -198,6 +205,7 @@ private:
|
||||
CrashEvent crashEvent;
|
||||
|
||||
flat_hash_map<uint64_t, ContextSwitch*, nohash<uint64_t>> ctxSwitch;
|
||||
std::pair<uint64_t, ContextSwitch*> ctxSwitchLast;
|
||||
};
|
||||
|
||||
struct MbpsBlock
|
||||
@ -277,7 +285,11 @@ public:
|
||||
uint64_t GetFrameOffset() const { return m_data.frameOffset; }
|
||||
const FrameData* GetFramesBase() const { return m_data.framesBase; }
|
||||
const Vector<FrameData*>& GetFrames() const { return m_data.frames.Data(); }
|
||||
const ContextSwitch* const GetContextSwitchData( uint64_t thread ) const;
|
||||
const ContextSwitch* const GetContextSwitchData( uint64_t thread )
|
||||
{
|
||||
if( m_data.ctxSwitchLast.first == thread ) return m_data.ctxSwitchLast.second;
|
||||
return GetContextSwitchDataImpl( thread );
|
||||
}
|
||||
|
||||
int64_t GetFrameTime( const FrameData& fd, size_t idx ) const;
|
||||
int64_t GetFrameBegin( const FrameData& fd, size_t idx ) const;
|
||||
@ -479,6 +491,7 @@ private:
|
||||
StringLocation StoreString( char* str, size_t sz );
|
||||
uint16_t CompressThreadReal( uint64_t thread );
|
||||
uint16_t CompressThreadNew( uint64_t thread );
|
||||
const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread );
|
||||
|
||||
tracy_force_inline void ReadTimeline( FileRead& f, ZoneEvent* zone, uint16_t thread, int64_t& refTime );
|
||||
tracy_force_inline void ReadTimelinePre042( FileRead& f, ZoneEvent* zone, uint16_t thread, int fileVer );
|
||||
|
Loading…
Reference in New Issue
Block a user