mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-10 12:28:18 +00:00
Merge pull request #1428 from damcclos/damcclos/flame-thread-sort
Enhance Flame Graph View with Sorting Functionality
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include "../server/TracyWorker.hpp"
|
||||
#include "../server/tracy_robin_hood.h"
|
||||
#include "../server/TracyVector.hpp"
|
||||
#include "../server/tracy_pdqsort.h"
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
# include "TracyLlm.hpp"
|
||||
@@ -517,6 +518,16 @@ private:
|
||||
return it->second;
|
||||
}
|
||||
|
||||
tracy_force_inline void SortThreads()
|
||||
{
|
||||
pdqsort_branchless( m_threadOrder.begin(), m_threadOrder.end(), [this] ( const auto& lhs, const auto& rhs ) {
|
||||
if( lhs->groupHint != rhs->groupHint ) return lhs->groupHint < rhs->groupHint;
|
||||
const auto cmp = strcmp( m_worker.GetThreadName( lhs->id ), m_worker.GetThreadName( rhs->id ) );
|
||||
if( cmp != 0 ) return cmp < 0;
|
||||
return lhs->id < rhs->id;
|
||||
} );
|
||||
}
|
||||
|
||||
static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift );
|
||||
|
||||
static const char* DecodeContextSwitchState( uint8_t state );
|
||||
|
||||
@@ -1069,6 +1069,11 @@ void View::DrawFlameGraph()
|
||||
m_flameGraphViewEnd = 0;
|
||||
m_flameGraphPan = 0;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if( ImGui::SmallButton( "Sort" ) )
|
||||
{
|
||||
SortThreads();
|
||||
}
|
||||
|
||||
const auto& style = ImGui::GetStyle();
|
||||
float probe = 0;
|
||||
@@ -1084,7 +1089,7 @@ void View::DrawFlameGraph()
|
||||
const auto rows = ( tsz + cols - 1 ) / cols;
|
||||
const auto rowsVisible = std::min<float>( rows, 7.5f );
|
||||
const auto rowsHeight = ImGui::GetTextLineHeightWithSpacing() * rowsVisible;
|
||||
ImGui::BeginChild( "###flamegraphthreadrows", ImVec2( -1, rowsHeight ) );
|
||||
ImGui::BeginChild( "###flamegraphthreadrows", ImVec2( -1, rowsHeight ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar );
|
||||
|
||||
int idx = 0;
|
||||
ImGui::BeginTable( "##flamegraphthreadcols", cols, ImGuiTableFlags_NoSavedSettings );
|
||||
|
||||
@@ -698,12 +698,7 @@ void View::DrawOptions()
|
||||
ImGui::SameLine();
|
||||
if( ImGui::SmallButton( "Sort" ) )
|
||||
{
|
||||
pdqsort_branchless( m_threadOrder.begin(), m_threadOrder.end(), [this] ( const auto& lhs, const auto& rhs ) {
|
||||
if( lhs->groupHint != rhs->groupHint ) return lhs->groupHint < rhs->groupHint;
|
||||
const auto cmp = strcmp( m_worker.GetThreadName( lhs->id ), m_worker.GetThreadName( rhs->id ) );
|
||||
if( cmp != 0 ) return cmp < 0;
|
||||
return lhs->id < rhs->id;
|
||||
} );
|
||||
SortThreads();
|
||||
}
|
||||
|
||||
const auto wposx = ImGui::GetCursorScreenPos().x;
|
||||
|
||||
Reference in New Issue
Block a user