diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index b8edb275..4fa4b1d8 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -265,7 +265,8 @@ struct PlotItem enum class PlotType { User, - Memory + Memory, + SysTime }; struct PlotData diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 7c6d0e0e..902c0e31 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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 ); diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 75155efc..f5633473 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -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(); + 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; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index a991e9ee..30995ece 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -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; }; }