Add plot type "power" and Watt format.

Note that this technically breaks backwards compatibility of trace files
for 0.9.2 builds. But, whatever, as it's not yet released.
This commit is contained in:
Bartosz Taudul 2023-03-10 01:23:22 +01:00
parent 23705fd84c
commit 7d69103444
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
5 changed files with 15 additions and 4 deletions

View File

@ -16,6 +16,7 @@ enum TracyPlotFormatEnum
TracyPlotFormatNumber,
TracyPlotFormatMemory,
TracyPlotFormatPercentage,
TracyPlotFormatWatt
};
TRACY_API void ___tracy_set_thread_name( const char* name );

View File

@ -726,7 +726,8 @@ enum class PlotType : uint8_t
{
User,
Memory,
SysTime
SysTime,
Power
};
// Keep this in sync with enum in TracyC.h
@ -734,7 +735,8 @@ enum class PlotValueFormatting : uint8_t
{
Number,
Memory,
Percentage
Percentage,
Watt
};
struct PlotData

View File

@ -38,6 +38,9 @@ const char* TimelineItemPlot::HeaderLabel() const
}
case PlotType::SysTime:
return ICON_FA_GAUGE_HIGH " CPU usage";
case PlotType::Power:
sprintf( tmp, ICON_FA_BOLT " %s", m_worker.GetString( m_plot->name ) );
return tmp;
default:
assert( false );
return nullptr;

View File

@ -157,6 +157,8 @@ uint32_t GetPlotColor( const PlotData& plot, const Worker& worker )
return 0xFF2266CC;
case PlotType::SysTime:
return 0xFFBAB220;
case PlotType::Power:
return 0xFF33CC33;
default:
assert( false );
return 0;
@ -177,6 +179,9 @@ const char* FormatPlotValue( double val, PlotValueFormatting format )
case PlotValueFormatting::Percentage:
sprintf( buf, "%.2f%%", val );
break;
case PlotValueFormatting::Watt:
sprintf( buf, "%s W", RealToString( val ) );
break;
default:
assert( false );
break;

View File

@ -6698,8 +6698,8 @@ void Worker::ProcessSysPower( const QueueSysPower& ev )
CheckString( ev.name );
PlotData* plot = m_slab.AllocInit<PlotData>();
plot->name = ev.name;
plot->type = PlotType::User;
plot->format = PlotValueFormatting::Number;
plot->type = PlotType::Power;
plot->format = PlotValueFormatting::Watt;
plot->showSteps = false;
plot->fill = true;
plot->color = 0;