mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 04:43:53 +00:00
Allow disabling CPU usage graph.
This commit is contained in:
parent
c28bab59b5
commit
4372ad1bc3
@ -20,7 +20,7 @@ constexpr auto FileOptions = "options";
|
|||||||
constexpr auto FileAnnotations = "annotations";
|
constexpr auto FileAnnotations = "annotations";
|
||||||
|
|
||||||
enum : uint32_t { VersionTimeline = 0 };
|
enum : uint32_t { VersionTimeline = 0 };
|
||||||
enum : uint32_t { VersionOptions = 2 };
|
enum : uint32_t { VersionOptions = 3 };
|
||||||
enum : uint32_t { VersionAnnotations = 0 };
|
enum : uint32_t { VersionAnnotations = 0 };
|
||||||
|
|
||||||
UserData::UserData()
|
UserData::UserData()
|
||||||
@ -103,6 +103,7 @@ void UserData::LoadState( ViewData& data )
|
|||||||
fread( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
|
fread( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
|
||||||
fread( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
|
fread( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
|
||||||
fread( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
|
fread( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
|
||||||
|
fread( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
|
||||||
fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
|
fread( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
|
||||||
}
|
}
|
||||||
fclose( f );
|
fclose( f );
|
||||||
@ -141,6 +142,7 @@ void UserData::SaveState( const ViewData& data )
|
|||||||
fwrite( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
|
fwrite( &data.drawContextSwitches, 1, sizeof( data.drawContextSwitches ), f );
|
||||||
fwrite( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
|
fwrite( &data.darkenContextSwitches, 1, sizeof( data.darkenContextSwitches ), f );
|
||||||
fwrite( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
|
fwrite( &data.drawCpuData, 1, sizeof( data.drawCpuData ), f );
|
||||||
|
fwrite( &data.drawCpuUsageGraph, 1, sizeof( data.drawCpuUsageGraph ), f );
|
||||||
fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
|
fwrite( &data.dynamicColors, 1, sizeof( data.dynamicColors ), f );
|
||||||
fclose( f );
|
fclose( f );
|
||||||
}
|
}
|
||||||
|
@ -4408,35 +4408,38 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
|
|||||||
const auto cpuCnt = m_worker.GetCpuDataCpuCount();
|
const auto cpuCnt = m_worker.GetCpuDataCpuCount();
|
||||||
assert( cpuCnt != 0 );
|
assert( cpuCnt != 0 );
|
||||||
|
|
||||||
const auto cpuUsageHeight = floor( 40.f * ImGui::GetTextLineHeight() / 15.f );
|
if( m_vd.drawCpuUsageGraph )
|
||||||
if( wpos.y + offset + cpuUsageHeight + 3 >= yMin && wpos.y + offset <= yMax )
|
|
||||||
{
|
{
|
||||||
const float cpuCntRev = 1.f / cpuCnt;
|
const auto cpuUsageHeight = floor( 40.f * ImGui::GetTextLineHeight() / 15.f );
|
||||||
float pos = 0;
|
if( wpos.y + offset + cpuUsageHeight + 3 >= yMin && wpos.y + offset <= yMax )
|
||||||
int usageOwn, usageOther;
|
|
||||||
while( pos < w )
|
|
||||||
{
|
{
|
||||||
m_worker.GetCpuUsageAtTime( m_vd.zvStart + pos * nspx, usageOwn, usageOther );
|
const float cpuCntRev = 1.f / cpuCnt;
|
||||||
float base;
|
float pos = 0;
|
||||||
if( usageOwn != 0 )
|
int usageOwn, usageOther;
|
||||||
|
while( pos < w )
|
||||||
{
|
{
|
||||||
base = wpos.y + offset + ( 1.f - usageOwn * cpuCntRev ) * cpuUsageHeight;
|
m_worker.GetCpuUsageAtTime( m_vd.zvStart + pos * nspx, usageOwn, usageOther );
|
||||||
draw->AddLine( ImVec2( wpos.x + pos, wpos.y + offset + cpuUsageHeight ), ImVec2( wpos.x + pos, base ), 0xFF55BB55 );
|
float base;
|
||||||
|
if( usageOwn != 0 )
|
||||||
|
{
|
||||||
|
base = wpos.y + offset + ( 1.f - usageOwn * cpuCntRev ) * cpuUsageHeight;
|
||||||
|
draw->AddLine( ImVec2( wpos.x + pos, wpos.y + offset + cpuUsageHeight ), ImVec2( wpos.x + pos, base ), 0xFF55BB55 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base = wpos.y + offset + cpuUsageHeight;
|
||||||
|
}
|
||||||
|
if( usageOther != 0 )
|
||||||
|
{
|
||||||
|
int usageTotal = usageOwn + usageOther;
|
||||||
|
draw->AddLine( ImVec2( wpos.x + pos, base ), ImVec2( wpos.x + pos, wpos.y + offset + ( 1.f - usageTotal * cpuCntRev ) * cpuUsageHeight ), 0xFF666666 );
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
else
|
draw->AddLine( wpos + ImVec2( 0, offset+cpuUsageHeight+2 ), wpos + ImVec2( w, offset+cpuUsageHeight+2 ), 0x22DD88DD );
|
||||||
{
|
|
||||||
base = wpos.y + offset + cpuUsageHeight;
|
|
||||||
}
|
|
||||||
if( usageOther != 0 )
|
|
||||||
{
|
|
||||||
int usageTotal = usageOwn + usageOther;
|
|
||||||
draw->AddLine( ImVec2( wpos.x + pos, base ), ImVec2( wpos.x + pos, wpos.y + offset + ( 1.f - usageTotal * cpuCntRev ) * cpuUsageHeight ), 0xFF666666 );
|
|
||||||
}
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
draw->AddLine( wpos + ImVec2( 0, offset+cpuUsageHeight+2 ), wpos + ImVec2( w, offset+cpuUsageHeight+2 ), 0x22DD88DD );
|
offset += cpuUsageHeight + 3;
|
||||||
}
|
}
|
||||||
offset += cpuUsageHeight + 3;
|
|
||||||
|
|
||||||
const auto origOffset = offset;
|
const auto origOffset = offset;
|
||||||
for( int i=0; i<cpuCnt; i++ )
|
for( int i=0; i<cpuCnt; i++ )
|
||||||
@ -6789,15 +6792,15 @@ void View::DrawOptions()
|
|||||||
ImGui::Checkbox( "Draw context switches", &val );
|
ImGui::Checkbox( "Draw context switches", &val );
|
||||||
#endif
|
#endif
|
||||||
m_vd.drawContextSwitches = val;
|
m_vd.drawContextSwitches = val;
|
||||||
val = m_vd.darkenContextSwitches;
|
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
|
val = m_vd.darkenContextSwitches;
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
ImGui::Checkbox( ICON_FA_MOON " Darken inactive threads", &val );
|
ImGui::Checkbox( ICON_FA_MOON " Darken inactive threads", &val );
|
||||||
#else
|
#else
|
||||||
ImGui::Checkbox( "Darken inactive threads", &val );
|
ImGui::Checkbox( "Darken inactive threads", &val );
|
||||||
#endif
|
#endif
|
||||||
ImGui::Unindent();
|
|
||||||
m_vd.darkenContextSwitches = val;
|
m_vd.darkenContextSwitches = val;
|
||||||
|
ImGui::Unindent();
|
||||||
val = m_vd.drawCpuData;
|
val = m_vd.drawCpuData;
|
||||||
#ifdef TRACY_EXTENDED_FONT
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
ImGui::Checkbox( ICON_FA_SLIDERS_H " Draw CPU data", &val );
|
ImGui::Checkbox( ICON_FA_SLIDERS_H " Draw CPU data", &val );
|
||||||
@ -6805,6 +6808,15 @@ void View::DrawOptions()
|
|||||||
ImGui::Checkbox( "Draw CPU data", &val );
|
ImGui::Checkbox( "Draw CPU data", &val );
|
||||||
#endif
|
#endif
|
||||||
m_vd.drawCpuData = val;
|
m_vd.drawCpuData = val;
|
||||||
|
ImGui::Indent();
|
||||||
|
val = m_vd.drawCpuUsageGraph;
|
||||||
|
#ifdef TRACY_EXTENDED_FONT
|
||||||
|
ImGui::Checkbox( ICON_FA_SIGNATURE " Draw CPU usage graph", &val );
|
||||||
|
#else
|
||||||
|
ImGui::Checkbox( "Draw CPU usage graph", &val );
|
||||||
|
#endif
|
||||||
|
m_vd.drawCpuUsageGraph = val;
|
||||||
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ struct ViewData
|
|||||||
uint8_t drawContextSwitches = true;
|
uint8_t drawContextSwitches = true;
|
||||||
uint8_t darkenContextSwitches = true;
|
uint8_t darkenContextSwitches = true;
|
||||||
uint8_t drawCpuData = true;
|
uint8_t drawCpuData = true;
|
||||||
|
uint8_t drawCpuUsageGraph = true;
|
||||||
uint8_t dynamicColors = true;
|
uint8_t dynamicColors = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user