Allow sorting find zone groups by mean time per call.

This commit is contained in:
Bartosz Taudul 2019-01-30 01:54:18 +01:00
parent c5fd347401
commit b0d319890b
2 changed files with 14 additions and 1 deletions

View File

@ -5529,6 +5529,16 @@ void View::DrawFindZone()
ImGui::RadioButton( "Count", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Count ); ImGui::RadioButton( "Count", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Count );
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton( "Time", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Time ); ImGui::RadioButton( "Time", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Time );
ImGui::SameLine();
ImGui::RadioButton( "MTPC", (int*)( &m_findZone.sortBy ), (int)FindZone::SortBy::Mtpc );
ImGui::SameLine();
ImGui::TextDisabled( "(?)" );
if( ImGui::IsItemHovered() )
{
ImGui::BeginTooltip();
ImGui::Text( "Mean time per call" );
ImGui::EndTooltip();
}
auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones; auto& zones = m_worker.GetZonesForSourceLocation( m_findZone.match[m_findZone.selMatch] ).zones;
auto sz = zones.size(); auto sz = zones.size();
@ -5601,6 +5611,9 @@ void View::DrawFindZone()
case FindZone::SortBy::Time: case FindZone::SortBy::Time:
pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } ); pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return lhs->second.time > rhs->second.time; } );
break; break;
case FindZone::SortBy::Mtpc:
pdqsort_branchless( groups.begin(), groups.end(), []( const auto& lhs, const auto& rhs ) { return double( lhs->second.time ) / lhs->second.zones.size() > double( rhs->second.time ) / rhs->second.zones.size(); } );
break;
default: default:
assert( false ); assert( false );
break; break;

View File

@ -290,7 +290,7 @@ private:
struct FindZone { struct FindZone {
enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 }; enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 };
enum class GroupBy : int { Thread, UserText, Callstack }; enum class GroupBy : int { Thread, UserText, Callstack };
enum class SortBy : int { Order, Count, Time }; enum class SortBy : int { Order, Count, Time, Mtpc };
struct Group struct Group
{ {