mirror of
https://github.com/wolfpld/tracy
synced 2025-05-08 16:03:53 +00:00
Merged in dedmenmiller/tracy/findZoneSorting (pull request #31)
Add sorting for findZone zonelist
This commit is contained in:
commit
8fb6c0dfcb
@ -5670,11 +5670,11 @@ void View::DrawFindZone()
|
|||||||
{
|
{
|
||||||
ImGui::Columns( 3, hdrString );
|
ImGui::Columns( 3, hdrString );
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::Text( "Time from start" );
|
if( ImGui::SmallButton( "Time from start" ) ) m_findZone.tableSortBy = FindZone::TableSortBy::Starttime;
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Text( "Execution time" );
|
if( ImGui::SmallButton( "Execution time" ) ) m_findZone.tableSortBy = FindZone::TableSortBy::Runtime;
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Text( "Name" );
|
if( ImGui::SmallButton( "Name" ) ) m_findZone.tableSortBy = FindZone::TableSortBy::Name;
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "(?)" );
|
ImGui::TextDisabled( "(?)" );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
@ -5686,7 +5686,44 @@ void View::DrawFindZone()
|
|||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
for( auto& ev : v->second.zones )
|
Vector<ZoneEvent*>* zonesToIterate = &v->second.zones;
|
||||||
|
Vector<ZoneEvent*> sortedZones;
|
||||||
|
|
||||||
|
if ( m_findZone.tableSortBy != FindZone::TableSortBy::Starttime )
|
||||||
|
{
|
||||||
|
zonesToIterate = &sortedZones;
|
||||||
|
sortedZones.reserve_and_use( v->second.zones.size() );
|
||||||
|
memcpy(sortedZones.data(), v->second.zones.data(), sizeof(ZoneEvent*)*v->second.zones.size());
|
||||||
|
|
||||||
|
switch( m_findZone.tableSortBy )
|
||||||
|
{
|
||||||
|
case FindZone::TableSortBy::Runtime:
|
||||||
|
if( m_findZone.selfTime )
|
||||||
|
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs )
|
||||||
|
{
|
||||||
|
return (m_worker.GetZoneEndDirect( *lhs ) - lhs->start - GetZoneChildTimeFast( *lhs ))
|
||||||
|
>
|
||||||
|
(m_worker.GetZoneEndDirect( *rhs ) - rhs->start - GetZoneChildTimeFast( *rhs ));
|
||||||
|
} );
|
||||||
|
else
|
||||||
|
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs ) { return (m_worker.GetZoneEndDirect( *lhs ) - lhs->start) > (m_worker.GetZoneEndDirect( *rhs ) - rhs->start); } );
|
||||||
|
break;
|
||||||
|
case FindZone::TableSortBy::Name:
|
||||||
|
pdqsort_branchless( sortedZones.begin(), sortedZones.end(), [this]( const auto& lhs, const auto& rhs )
|
||||||
|
{
|
||||||
|
if (lhs->name.active != rhs->name.active) return lhs->name.active > rhs->name.active;
|
||||||
|
|
||||||
|
return strcmp(m_worker.GetString( lhs->name ), m_worker.GetString( rhs->name )) < 0;
|
||||||
|
} );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for( auto& ev : *zonesToIterate )
|
||||||
{
|
{
|
||||||
const auto end = m_worker.GetZoneEndDirect( *ev );
|
const auto end = m_worker.GetZoneEndDirect( *ev );
|
||||||
auto timespan = end - ev->start;
|
auto timespan = end - ev->start;
|
||||||
|
@ -302,6 +302,7 @@ private:
|
|||||||
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, Mtpc };
|
enum class SortBy : int { Order, Count, Time, Mtpc };
|
||||||
|
enum class TableSortBy : int { Starttime, Runtime, Name };
|
||||||
|
|
||||||
struct Group
|
struct Group
|
||||||
{
|
{
|
||||||
@ -323,6 +324,7 @@ private:
|
|||||||
bool selfTime = false;
|
bool selfTime = false;
|
||||||
GroupBy groupBy = GroupBy::Thread;
|
GroupBy groupBy = GroupBy::Thread;
|
||||||
SortBy sortBy = SortBy::Count;
|
SortBy sortBy = SortBy::Count;
|
||||||
|
TableSortBy tableSortBy = TableSortBy::Starttime;
|
||||||
Region highlight;
|
Region highlight;
|
||||||
int64_t hlOrig_t0, hlOrig_t1;
|
int64_t hlOrig_t0, hlOrig_t1;
|
||||||
int64_t numBins = -1;
|
int64_t numBins = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user