Add display of per-line sample time as a program run time percentage.

This commit is contained in:
Bartosz Taudul 2024-03-23 13:47:03 +01:00
parent adbee2f820
commit ef9f2d247d
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -3257,7 +3257,17 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add
{ {
if( m_cost == CostType::SampleCount ) if( m_cost == CostType::SampleCount )
{ {
if( worker ) TextFocused( "Local time:", TimeToString( ipcnt.local * worker->GetSamplingPeriod() ) ); if( worker )
{
const auto time = ipcnt.local * worker->GetSamplingPeriod();
TextFocused( "Local time:", TimeToString( time ) );
const auto timePct = 100.f * time / worker->GetLastTime();
if( timePct >= 0.01f )
{
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%% run time)", timePct );
}
}
TextFocused( "Local samples:", RealToString( ipcnt.local ) ); TextFocused( "Local samples:", RealToString( ipcnt.local ) );
} }
else else
@ -3267,7 +3277,17 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add
} }
if( ipcnt.ext ) if( ipcnt.ext )
{ {
if( worker ) TextFocused( "Child time:", TimeToString( ipcnt.ext * worker->GetSamplingPeriod() ) ); if( worker )
{
const auto time = ipcnt.ext * worker->GetSamplingPeriod();
TextFocused( "Child time:", TimeToString( time ) );
const auto timePct = 100.f * time / worker->GetLastTime();
if( timePct >= 0.01f )
{
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%% run time)", timePct );
}
}
TextFocused( "Child samples:", RealToString( ipcnt.ext ) ); TextFocused( "Child samples:", RealToString( ipcnt.ext ) );
} }
if( hasHwData ) PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, false ); if( hasHwData ) PrintHwSampleTooltip( cycles, retired, cacheRef, cacheMiss, branchRetired, branchMiss, false );
@ -3584,7 +3604,14 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
{ {
if( m_cost == CostType::SampleCount ) if( m_cost == CostType::SampleCount )
{ {
TextFocused( "Local time:", TimeToString( ipcnt.local * worker.GetSamplingPeriod() ) ); const auto time = ipcnt.local * worker.GetSamplingPeriod();
TextFocused( "Local time:", TimeToString( time ) );
const auto timePct = 100.f * time / worker.GetLastTime();
if( timePct >= 0.01f )
{
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%% run time)", timePct );
}
TextFocused( "Local samples:", RealToString( ipcnt.local ) ); TextFocused( "Local samples:", RealToString( ipcnt.local ) );
} }
else else
@ -3594,7 +3621,14 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
} }
if( ipcnt.ext ) if( ipcnt.ext )
{ {
TextFocused( "Child time:", TimeToString( ipcnt.ext * worker.GetSamplingPeriod() ) ); const auto time = ipcnt.ext * worker.GetSamplingPeriod();
TextFocused( "Child time:", TimeToString( time ) );
const auto timePct = 100.f * time / worker.GetLastTime();
if( timePct >= 0.01f )
{
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%% run time)", timePct );
}
TextFocused( "Child samples:", RealToString( ipcnt.ext ) ); TextFocused( "Child samples:", RealToString( ipcnt.ext ) );
} }