mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Save/load per-cpu context switches.
This commit is contained in:
parent
8bc4258e29
commit
cef7e4b8d0
@ -626,6 +626,9 @@ int main( int argc, char** argv )
|
||||
case tracy::LoadProgress::ContextSwitches:
|
||||
ImGui::TextUnformatted( "Context switches..." );
|
||||
break;
|
||||
case tracy::LoadProgress::ContextSwitchesPerCpu:
|
||||
ImGui::TextUnformatted( "CPU context switches..." );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@ namespace Version
|
||||
{
|
||||
enum { Major = 0 };
|
||||
enum { Minor = 5 };
|
||||
enum { Patch = 2 };
|
||||
enum { Patch = 3 };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,10 +307,14 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
{
|
||||
s_loadProgress.total.store( 9, std::memory_order_relaxed );
|
||||
}
|
||||
else
|
||||
else if( fileVer <= FileVersion( 0, 5, 2 ) )
|
||||
{
|
||||
s_loadProgress.total.store( 10, std::memory_order_relaxed );
|
||||
}
|
||||
else
|
||||
{
|
||||
s_loadProgress.total.store( 11, std::memory_order_relaxed );
|
||||
}
|
||||
|
||||
s_loadProgress.subTotal.store( 0, std::memory_order_relaxed );
|
||||
s_loadProgress.progress.store( LoadProgress::Initialization, std::memory_order_relaxed );
|
||||
@ -1429,6 +1433,44 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
}
|
||||
}
|
||||
|
||||
if( fileVer >= FileVersion( 0, 5, 3 ) )
|
||||
{
|
||||
s_loadProgress.subTotal.store( 0, std::memory_order_relaxed );
|
||||
s_loadProgress.progress.store( LoadProgress::ContextSwitchesPerCpu, std::memory_order_relaxed );
|
||||
f.Read( sz );
|
||||
s_loadProgress.subTotal.store( sz, std::memory_order_relaxed );
|
||||
if( eventMask & EventType::ContextSwitches )
|
||||
{
|
||||
uint64_t cnt = 0;
|
||||
for( int i=0; i<256; i++ )
|
||||
{
|
||||
int64_t refTime = 0;
|
||||
f.Read( sz );
|
||||
m_data.cpuData[i].cs.reserve_exact( sz, m_slab );
|
||||
auto ptr = m_data.cpuData[i].cs.data();
|
||||
for( uint64_t j=0; j<sz; j++ )
|
||||
{
|
||||
ptr->SetStart( ReadTimeOffset( f, refTime ) );
|
||||
ptr->SetEnd( ReadTimeOffset( f, refTime ) );
|
||||
uint64_t thread;
|
||||
f.Read( thread );
|
||||
ptr->SetThread( thread );
|
||||
ptr++;
|
||||
}
|
||||
cnt += sz;
|
||||
s_loadProgress.subProgress.store( cnt, std::memory_order_relaxed );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i=0; i<256; i++ )
|
||||
{
|
||||
f.Read( sz );
|
||||
f.Skip( sizeof( uint64_t ) * 3 * sz );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_loadProgress.total.store( 0, std::memory_order_relaxed );
|
||||
m_loadTime = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now() - loadStart ).count();
|
||||
|
||||
@ -4826,6 +4868,24 @@ void Worker::Write( FileWrite& f )
|
||||
f.Write( &state, sizeof( state ) );
|
||||
}
|
||||
}
|
||||
|
||||
sz = GetContextSwitchPerCpuCount();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
for( int i=0; i<256; i++ )
|
||||
{
|
||||
sz = m_data.cpuData[i].cs.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
int64_t refTime = 0;
|
||||
for( auto& cx : m_data.cpuData[i].cs )
|
||||
{
|
||||
WriteTimeOffset( f, refTime, cx.Start() );
|
||||
WriteTimeOffset( f, refTime, cx.End() );
|
||||
uint64_t thread = cx.Thread();
|
||||
// Don't care about external thread identifiers
|
||||
if( m_data.threadMap.find( thread ) == m_data.threadMap.end() ) thread = 0;
|
||||
f.Write( &thread, sizeof( thread ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime )
|
||||
|
@ -67,7 +67,8 @@ struct LoadProgress
|
||||
Memory,
|
||||
CallStacks,
|
||||
FrameImages,
|
||||
ContextSwitches
|
||||
ContextSwitches,
|
||||
ContextSwitchesPerCpu
|
||||
};
|
||||
|
||||
LoadProgress() : total( 0 ), progress( 0 ), subTotal( 0 ), subProgress( 0 ) {}
|
||||
|
Loading…
Reference in New Issue
Block a user