diff --git a/profiler/src/profiler/TracyView_Compare.cpp b/profiler/src/profiler/TracyView_Compare.cpp index 570da504..cf8151bc 100644 --- a/profiler/src/profiler/TracyView_Compare.cpp +++ b/profiler/src/profiler/TracyView_Compare.cpp @@ -8,6 +8,7 @@ #include "TracyFileselector.hpp" #include "TracyPrint.hpp" #include "TracyView.hpp" +#include "tracy_pdqsort.h" namespace tracy { @@ -400,9 +401,9 @@ void View::DrawCompare() } } - std::sort( m_compare.thisUnique.begin(), m_compare.thisUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); - std::sort( m_compare.secondUnique.begin(), m_compare.secondUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); - std::sort( m_compare.diffs.begin(), m_compare.diffs.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs.first, rhs.first ) < 0; } ); + pdqsort_branchless( m_compare.thisUnique.begin(), m_compare.thisUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); + pdqsort_branchless( m_compare.secondUnique.begin(), m_compare.secondUnique.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); + pdqsort_branchless( m_compare.diffs.begin(), m_compare.diffs.end(), []( const auto& lhs, const auto& rhs ) { return strcmp( lhs.first, rhs.first ) < 0; } ); } } diff --git a/profiler/src/profiler/TracyView_FlameGraph.cpp b/profiler/src/profiler/TracyView_FlameGraph.cpp index 4a31f1a9..b1b0475b 100644 --- a/profiler/src/profiler/TracyView_FlameGraph.cpp +++ b/profiler/src/profiler/TracyView_FlameGraph.cpp @@ -4,6 +4,7 @@ #include "TracyPrint.hpp" #include "TracyVector.hpp" #include "TracyView.hpp" +#include "tracy_pdqsort.h" namespace tracy { @@ -147,7 +148,7 @@ static void BuildFlameGraph( const Worker& worker, Vector& data, static void SortFlameGraph( Vector& data ) { - std::sort( data.begin(), data.end(), []( const FlameGraphItem& lhs, const FlameGraphItem& rhs ) { return lhs.time > rhs.time; } ); + pdqsort_branchless( data.begin(), data.end(), []( const FlameGraphItem& lhs, const FlameGraphItem& rhs ) { return lhs.time > rhs.time; } ); for( auto& v : data ) SortFlameGraph( v.children ); } diff --git a/profiler/src/profiler/TracyView_Options.cpp b/profiler/src/profiler/TracyView_Options.cpp index e17d7665..e446ec56 100644 --- a/profiler/src/profiler/TracyView_Options.cpp +++ b/profiler/src/profiler/TracyView_Options.cpp @@ -8,6 +8,7 @@ #include "TracyTimelineItemGpu.hpp" #include "TracyUtility.hpp" #include "TracyView.hpp" +#include "tracy_pdqsort.h" namespace tracy { @@ -194,7 +195,7 @@ void View::DrawOptions() } while( idx < NumSlopes ); } - std::sort( slopes, slopes+NumSlopes ); + pdqsort_branchless( slopes, slopes+NumSlopes ); drift = int( 1000000000 * -slopes[NumSlopes/2] ); } } @@ -674,7 +675,7 @@ void View::DrawOptions() ImGui::SameLine(); if( ImGui::SmallButton( "Sort" ) ) { - std::sort( m_threadOrder.begin(), m_threadOrder.end(), [this] ( const auto& lhs, const auto& rhs ) { + 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; return strcmp( m_worker.GetThreadName( lhs->id ), m_worker.GetThreadName( rhs->id ) ) < 0; } ); diff --git a/profiler/src/profiler/TracyView_Statistics.cpp b/profiler/src/profiler/TracyView_Statistics.cpp index 55ca58aa..a8e5c5f3 100644 --- a/profiler/src/profiler/TracyView_Statistics.cpp +++ b/profiler/src/profiler/TracyView_Statistics.cpp @@ -4,6 +4,7 @@ #include "TracyImGui.hpp" #include "TracyPrint.hpp" #include "TracyView.hpp" +#include "tracy_pdqsort.h" namespace tracy { @@ -487,7 +488,7 @@ void View::DrawStatistics() { imgNames.emplace_back( m_worker.GetString( img ) ); } - std::sort( imgNames.begin(), imgNames.end(), [] ( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); + pdqsort_branchless( imgNames.begin(), imgNames.end(), [] ( const auto& lhs, const auto& rhs ) { return strcmp( lhs, rhs ) < 0; } ); for( auto& img : imgNames ) { bool sel = false; diff --git a/profiler/src/profiler/TracyView_TraceInfo.cpp b/profiler/src/profiler/TracyView_TraceInfo.cpp index 9accf191..7a312af8 100644 --- a/profiler/src/profiler/TracyView_TraceInfo.cpp +++ b/profiler/src/profiler/TracyView_TraceInfo.cpp @@ -3,6 +3,7 @@ #include "TracyImGui.hpp" #include "TracyPrint.hpp" #include "TracyView.hpp" +#include "tracy_pdqsort.h" namespace tracy { @@ -752,7 +753,7 @@ void View::DrawInfo() std::vector tsort; tsort.reserve( topology.size() ); for( auto it = topology.begin(); it != topology.end(); ++it ) tsort.emplace_back( it ); - std::sort( tsort.begin(), tsort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); + pdqsort_branchless( tsort.begin(), tsort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); for( auto& package : tsort ) { if( package->first != 0 ) dpos.y += ty; @@ -763,7 +764,7 @@ void View::DrawInfo() std::vectorsecond.begin())> dsort; dsort.reserve( package->second.size() ); for( auto it = package->second.begin(); it != package->second.end(); ++it ) dsort.emplace_back( it ); - std::sort( dsort.begin(), dsort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); + pdqsort_branchless( dsort.begin(), dsort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); for( auto& die : dsort ) { dpos.y += small; @@ -786,7 +787,7 @@ void View::DrawInfo() std::vectorsecond.begin())> csort; csort.reserve( die->second.size() ); for( auto it = die->second.begin(); it != die->second.end(); ++it ) csort.emplace_back( it ); - std::sort( csort.begin(), csort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); + pdqsort_branchless( csort.begin(), csort.end(), [] ( const auto& l, const auto& r ) { return l->first < r->first; } ); auto cpos = dpos + ImVec2( margin, margin ); int ll = cpl; for( auto& core : csort )