1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Collect per-cpu context switch data.

This commit is contained in:
Bartosz Taudul
2019-08-16 16:28:58 +02:00
parent 9e0fe226df
commit 69527d2f71
3 changed files with 42 additions and 0 deletions
+11
View File
@@ -3963,6 +3963,7 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
const auto time = TscTime( ev.time - m_data.baseTime );
m_data.lastTime = std::max( m_data.lastTime, time );
auto& cs = m_data.cpuData[ev.cpu].cs;
if( ev.oldThread != 0 )
{
auto it = m_data.ctxSwitch.find( ev.oldThread );
@@ -3978,6 +3979,12 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
it->second->runningTime += time - item.Start();
}
if( !cs.empty() )
{
auto& cx = cs.back();
assert( cx.Thread() == ev.oldThread );
cx.SetEnd( time );
}
}
if( ev.newThread != 0 )
{
@@ -3995,6 +4002,10 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
item.SetCpu( ev.cpu );
item.SetReason( -1 );
item.SetState( -1 );
auto& cx = cs.push_next();
cx.SetStart( time );
cx.SetThread( ev.newThread );
}
}