Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-08-13 01:13:50 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-08-13 03:35:32 +0300
commit419f74280d10e05a6bd499bbafa7ec3ef4b51f6f (patch)
tree5ccd299f04eb30608e87f3791deae7bc8a90b883 /server/TracyWorker.cpp
parent90d26cb1b691dff8cf7b3a1b4dd10f98e669dbb9 (diff)
Store context switches.
Diffstat (limited to 'server/TracyWorker.cpp')
-rw-r--r--server/TracyWorker.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index c9e4a79a..2339003b 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -2611,6 +2611,9 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::SysTimeReport:
ProcessSysTime( ev.sysTime );
break;
+ case QueueType::ContextSwitch:
+ ProcessContextSwitch( ev.contextSwitch );
+ break;
default:
assert( false );
break;
@@ -3629,6 +3632,44 @@ void Worker::ProcessSysTime( const QueueSysTime& ev )
}
}
+void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
+{
+ const auto time = TscTime( ev.time );
+ m_data.lastTime = std::max( m_data.lastTime, time );
+
+ if( ev.oldThread != 0 )
+ {
+ auto it = m_data.ctxSwitch.find( ev.oldThread );
+ if( it != m_data.ctxSwitch.end() )
+ {
+ auto& data = it->second->v;
+ assert( !data.empty() );
+ auto& item = data.back();
+ assert( item.start <= time );
+ item.end = time;
+ item.reason = ev.reason;
+ item.state = ev.state;
+ }
+ }
+ if( ev.newThread != 0 )
+ {
+ auto it = m_data.ctxSwitch.find( ev.newThread );
+ if( it == m_data.ctxSwitch.end() )
+ {
+ auto ctx = m_slab.AllocInit<ContextSwitch>();
+ it = m_data.ctxSwitch.emplace( ev.newThread, ctx ).first;
+ }
+ auto& data = it->second->v;
+ assert( data.empty() || (uint64_t)data.back().end <= time );
+ auto& item = data.push_next();
+ item.start = time;
+ item.end = -1;
+ item.cpu = ev.cpu;
+ item.reason = -1;
+ item.state = -1;
+ }
+}
+
void Worker::MemAllocChanged( int64_t time )
{
const auto val = (double)m_data.memory.usage;