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
+29
View File
@@ -252,6 +252,30 @@ struct ContextSwitchData
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };
// Thread can't be compressed here, because we want to ignore external threads and we can't
// determine whether thread is local or external when context information arrives (thread data
// might come after context switch data).
struct ContextSwitchCpu
{
int64_t Start() const { return int64_t( _start_thread1 ) >> 16; }
void SetStart( int64_t start ) { assert( start < ( 1ll << 47 ) ); _start_thread1 = ( _start_thread1 & 0xFFFF ) | uint64_t( start << 16 ); }
int64_t End() const { return int64_t( _end_thread2 ) >> 16; }
void SetEnd( int64_t end ) { assert( end < ( 1ll << 47 ) ); _end_thread2 = ( _end_thread2 & 0xFFFF ) | uint64_t( end << 16 ); }
uint64_t Thread() const { return uint64_t( uint16_t( _start_thread1 ) ) | ( uint64_t( uint16_t( _end_thread2 ) ) << 16 ) | ( uint64_t( _thread3 ) << 32 ); }
void SetThread( uint64_t thread ) {
_start_thread1 = ( _start_thread1 & 0xFFFFFFFFFFFF0000 ) | uint16_t( thread );
_end_thread2 = ( _end_thread2 & 0xFFFFFFFFFFFF0000 ) | uint16_t( thread >> 16 );
_thread3 = uint32_t( thread >> 32 );
}
uint64_t _start_thread1;
uint64_t _end_thread2;
uint32_t _thread3;
};
enum { ContextSwitchCpuSize = sizeof( ContextSwitchCpu ) };
struct MessageData
{
int64_t time;
@@ -409,6 +433,11 @@ struct ContextSwitch
int64_t runningTime = 0;
};
struct CpuData
{
Vector<ContextSwitchCpu> cs;
};
}
#endif