Support displaying self times in statistics view.

This commit is contained in:
Bartosz Taudul 2018-06-06 00:47:16 +02:00
parent e5d35d443d
commit 859bf01992
2 changed files with 25 additions and 4 deletions

View File

@ -183,6 +183,7 @@ View::View( const char* addr )
, m_drawPlots( true ) , m_drawPlots( true )
, m_onlyContendedLocks( false ) , m_onlyContendedLocks( false )
, m_statSort( 0 ) , m_statSort( 0 )
, m_statSelf( false )
, m_namespace( Namespace::Full ) , m_namespace( Namespace::Full )
{ {
assert( s_instance == nullptr ); assert( s_instance == nullptr );
@ -216,6 +217,7 @@ View::View( FileRead& f )
, m_drawPlots( true ) , m_drawPlots( true )
, m_onlyContendedLocks( false ) , m_onlyContendedLocks( false )
, m_statSort( 0 ) , m_statSort( 0 )
, m_statSelf( false )
, m_namespace( Namespace::Full ) , m_namespace( Namespace::Full )
{ {
assert( s_instance == nullptr ); assert( s_instance == nullptr );
@ -4609,6 +4611,8 @@ void View::DrawStatistics()
return; return;
} }
ImGui::Checkbox( "Show self times", &m_statSelf );
auto& slz = m_worker.GetSourceLocationZones(); auto& slz = m_worker.GetSourceLocationZones();
Vector<decltype(slz.begin())> srcloc; Vector<decltype(slz.begin())> srcloc;
srcloc.reserve( slz.size() ); srcloc.reserve( slz.size() );
@ -4619,16 +4623,31 @@ void View::DrawStatistics()
srcloc.push_back_no_space_check( it ); srcloc.push_back_no_space_check( it );
} }
} }
switch( m_statSort ) switch( m_statSort )
{ {
case 0: case 0:
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.total > rhs->second.total; } ); if( m_statSelf )
{
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.selfTotal > rhs->second.selfTotal; } );
}
else
{
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.total > rhs->second.total; } );
}
break; break;
case 1: case 1:
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.zones.size() > rhs->second.zones.size(); } ); pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.zones.size() > rhs->second.zones.size(); } );
break; break;
case 2: case 2:
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.total / lhs->second.zones.size() > rhs->second.total / rhs->second.zones.size(); } ); if( m_statSelf )
{
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.selfTotal / lhs->second.zones.size() > rhs->second.selfTotal / rhs->second.zones.size(); } );
}
else
{
pdqsort_branchless( srcloc.begin(), srcloc.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.total / lhs->second.zones.size() > rhs->second.total / rhs->second.zones.size(); } );
}
break; break;
default: default:
assert( false ); assert( false );
@ -4672,11 +4691,11 @@ void View::DrawStatistics()
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text( "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line ); ImGui::Text( "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line );
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text( "%s", TimeToString( v->second.total ) ); ImGui::Text( "%s", TimeToString( m_statSelf ? v->second.selfTotal : v->second.total ) );
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text( "%s", RealToString( v->second.zones.size(), true ) ); ImGui::Text( "%s", RealToString( v->second.zones.size(), true ) );
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text( "%s", TimeToString( v->second.total / v->second.zones.size() ) ); ImGui::Text( "%s", TimeToString( ( m_statSelf ? v->second.selfTotal : v->second.total ) / v->second.zones.size() ) );
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::PopID(); ImGui::PopID();

View File

@ -185,7 +185,9 @@ private:
bool m_drawLocks; bool m_drawLocks;
bool m_drawPlots; bool m_drawPlots;
bool m_onlyContendedLocks; bool m_onlyContendedLocks;
int m_statSort; int m_statSort;
bool m_statSelf;
Namespace m_namespace; Namespace m_namespace;
Animation m_zoomAnim; Animation m_zoomAnim;