mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Add thread compression cache.
Observation: calls to CompressThread() are likely to be repeated with the same value. Exploit that by storing last query and its result.
This commit is contained in:
@@ -764,10 +764,24 @@ const Worker::SourceLocationZones& Worker::GetZonesForSourceLocation( int32_t sr
|
||||
#endif
|
||||
|
||||
uint16_t Worker::CompressThread( uint64_t thread )
|
||||
{
|
||||
if( m_data.threadLast.first == thread )
|
||||
{
|
||||
return m_data.threadLast.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CompressThreadReal( thread );
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t Worker::CompressThreadReal( uint64_t thread )
|
||||
{
|
||||
auto it = m_data.threadMap.find( thread );
|
||||
if( it != m_data.threadMap.end() )
|
||||
{
|
||||
m_data.threadLast.first = thread;
|
||||
m_data.threadLast.second = it->second;
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
@@ -781,6 +795,8 @@ uint16_t Worker::CompressThreadNew( uint64_t thread )
|
||||
auto sz = m_data.threadExpand.size();
|
||||
m_data.threadExpand.push_back( thread );
|
||||
m_data.threadMap.emplace( thread, sz );
|
||||
m_data.threadLast.first = thread;
|
||||
m_data.threadLast.second = sz;
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user