mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Process power usage messages.
This commit is contained in:
parent
2971db21e3
commit
69855c671f
@ -4744,6 +4744,9 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::SysTimeReport:
|
case QueueType::SysTimeReport:
|
||||||
ProcessSysTime( ev.sysTime );
|
ProcessSysTime( ev.sysTime );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::SysPowerReport:
|
||||||
|
ProcessSysPower( ev.sysPower );
|
||||||
|
break;
|
||||||
case QueueType::ContextSwitch:
|
case QueueType::ContextSwitch:
|
||||||
ProcessContextSwitch( ev.contextSwitch );
|
ProcessContextSwitch( ev.contextSwitch );
|
||||||
break;
|
break;
|
||||||
@ -6686,6 +6689,35 @@ void Worker::ProcessSysTime( const QueueSysTime& ev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessSysPower( const QueueSysPower& ev )
|
||||||
|
{
|
||||||
|
const auto time = TscTime( ev.time );
|
||||||
|
auto it = m_powerData.find( ev.name );
|
||||||
|
if( it == m_powerData.end() )
|
||||||
|
{
|
||||||
|
CheckString( ev.name );
|
||||||
|
PlotData* plot = m_slab.AllocInit<PlotData>();
|
||||||
|
plot->name = ev.name;
|
||||||
|
plot->type = PlotType::User;
|
||||||
|
plot->format = PlotValueFormatting::Number;
|
||||||
|
plot->showSteps = false;
|
||||||
|
plot->fill = true;
|
||||||
|
plot->color = 0;
|
||||||
|
m_data.plots.Data().push_back( plot );
|
||||||
|
m_powerData.emplace( ev.name, PowerData { time, plot } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto dt = time - it->second.lastTime;
|
||||||
|
it->second.lastTime = time;
|
||||||
|
if( m_data.lastTime < time ) m_data.lastTime = time;
|
||||||
|
// ev.delta is Microjoule, dt is nanoseconds
|
||||||
|
// power is Watt = J / s
|
||||||
|
const auto power = ev.delta * 1000. / dt;
|
||||||
|
InsertPlot( it->second.plot, time, power );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
|
void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
|
||||||
{
|
{
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
@ -158,6 +158,12 @@ public:
|
|||||||
uint8_t inlineFrame;
|
uint8_t inlineFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PowerData
|
||||||
|
{
|
||||||
|
int64_t lastTime;
|
||||||
|
PlotData* plot;
|
||||||
|
};
|
||||||
|
|
||||||
#pragma pack( push, 1 )
|
#pragma pack( push, 1 )
|
||||||
struct GhostKey
|
struct GhostKey
|
||||||
{
|
{
|
||||||
@ -735,6 +741,7 @@ private:
|
|||||||
tracy_force_inline void ProcessSymbolInformation( const QueueSymbolInformation& ev );
|
tracy_force_inline void ProcessSymbolInformation( const QueueSymbolInformation& ev );
|
||||||
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
||||||
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
||||||
|
tracy_force_inline void ProcessSysPower( const QueueSysPower& ev );
|
||||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||||
tracy_force_inline void ProcessThreadWakeup( const QueueThreadWakeup& ev );
|
tracy_force_inline void ProcessThreadWakeup( const QueueThreadWakeup& ev );
|
||||||
tracy_force_inline void ProcessTidToPid( const QueueTidToPid& ev );
|
tracy_force_inline void ProcessTidToPid( const QueueTidToPid& ev );
|
||||||
@ -1066,6 +1073,8 @@ private:
|
|||||||
unordered_flat_map<uint64_t, uint32_t> m_nextCallstack;
|
unordered_flat_map<uint64_t, uint32_t> m_nextCallstack;
|
||||||
unordered_flat_map<uint32_t, const char*> m_sourceCodeQuery;
|
unordered_flat_map<uint32_t, const char*> m_sourceCodeQuery;
|
||||||
uint32_t m_nextSourceCodeQuery = 0;
|
uint32_t m_nextSourceCodeQuery = 0;
|
||||||
|
|
||||||
|
unordered_flat_map<uint64_t, PowerData> m_powerData;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user