Process CPU usage reports.

This commit is contained in:
Bartosz Taudul 2019-02-21 22:45:39 +01:00
parent 9f4f5bcb63
commit e9baa80bf3
4 changed files with 38 additions and 1 deletions

View File

@ -265,7 +265,8 @@ struct PlotItem
enum class PlotType
{
User,
Memory
Memory,
SysTime
};
struct PlotData

View File

@ -8862,6 +8862,12 @@ const char* View::GetPlotName( const PlotData* plot ) const
return ICON_FA_MEMORY " Memory usage";
#else
return "Memory usage";
#endif
case PlotType::SysTime:
#ifdef TRACY_EXTENDED_FONT
return ICON_FA_TACHOMETER_ALT " CPU usage";
#else
return "CPU usage";
#endif
default:
assert( false );

View File

@ -2277,6 +2277,9 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::CrashReport:
ProcessCrashReport( ev.crashReport );
break;
case QueueType::SysTimeReport:
ProcessSysTime( ev.sysTime );
break;
default:
assert( false );
break;
@ -3096,6 +3099,30 @@ void Worker::ProcessCrashReport( const QueueCrashReport& ev )
m_data.m_crashEvent.callstack = 0;
}
void Worker::ProcessSysTime( const QueueSysTime& ev )
{
const auto time = TscTime( ev.time );
const auto val = ev.sysTime;
if( !m_sysTimePlot )
{
m_sysTimePlot = m_slab.AllocInit<PlotData>();
m_sysTimePlot->name = 0;
m_sysTimePlot->type = PlotType::SysTime;
m_sysTimePlot->min = val;
m_sysTimePlot->max = val;
m_sysTimePlot->data.push_back( { time, val } );
m_data.plots.Data().push_back( m_sysTimePlot );
}
else
{
assert( !m_sysTimePlot->data.empty() );
assert( m_sysTimePlot->data.back().time <= time );
if( m_sysTimePlot->min > val ) m_sysTimePlot->min = val;
else if( m_sysTimePlot->max < val ) m_sysTimePlot->max = val;
m_sysTimePlot->data.push_back_non_empty( { time, val } );
}
}
void Worker::MemAllocChanged( int64_t time )
{
const auto val = (double)m_data.memory.usage;

View File

@ -340,6 +340,7 @@ private:
tracy_force_inline void ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev );
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev );
@ -466,6 +467,8 @@ private:
Failure m_failure = Failure::None;
FailureData m_failureData;
PlotData* m_sysTimePlot = nullptr;
};
}