diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 2f887544..95c13fa1 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4146,60 +4146,211 @@ void View::DrawZoneInfoWindow() ImGui::TextDisabled( "(%s)", RealToString( children.size(), true ) ); if( expand ) { + const auto rztime = 1.0 / ztime; + const auto ty = ImGui::GetTextLineHeight(); + ImGui::SameLine(); if( ImGui::SmallButton( m_groupChildrenLocations ? "Display all children separate" : "Group children locations" ) ) m_groupChildrenLocations = !m_groupChildrenLocations; - auto ctt = std::make_unique( children.size() ); - auto cti = std::make_unique( children.size() ); - uint64_t ctime = 0; - for( size_t i=0; istart; - ctime += ct; - ctt[i] = ct; - cti[i] = uint32_t( i ); - } - - pdqsort_branchless( cti.get(), cti.get() + children.size(), [&ctt] ( const auto& lhs, const auto& rhs ) { return ctt[lhs] > ctt[rhs]; } ); - - const auto rztime = 1.0 / ztime; - const auto ty = ImGui::GetTextLineHeight(); - ImGui::Columns( 2 ); - ImGui::TextColored( ImVec4( 1.0f, 1.0f, 0.4f, 1.0f ), "Self time" ); - ImGui::NextColumn(); - char buf[128]; - sprintf( buf, "%s (%.2f%%)", TimeToString( ztime - ctime ), double( ztime - ctime ) / ztime * 100 ); - ImGui::ProgressBar( double( ztime - ctime ) * rztime, ImVec2( -1, ty ), buf ); - ImGui::NextColumn(); - for( size_t i=0; i v; + }; + uint64_t ctime = 0; + flat_hash_map> cmap; + cmap.reserve( 128 ); + for( size_t i=0; isecond.t += ct; + it->second.v.push_back( i ); } - ImGui::PopID(); + + auto msz = cmap.size(); + Vector cgvec; + cgvec.reserve_exact( msz ); + size_t idx = 0; + for( auto& it : cmap ) + { + cgvec[idx++] = &it.second; + } + + pdqsort_branchless( cgvec.begin(), cgvec.end(), []( const auto& lhs, const auto& rhs ) { return lhs->t > rhs->t; } ); + + ImGui::Columns( 2 ); + ImGui::TextColored( ImVec4( 1.0f, 1.0f, 0.4f, 1.0f ), "Self time" ); ImGui::NextColumn(); - const auto part = double( ctt[cti[i]] ) * rztime; char buf[128]; - sprintf( buf, "%s (%.2f%%)", TimeToString( ctt[cti[i]] ), part * 100 ); - ImGui::ProgressBar( part, ImVec2( -1, ty ), buf ); + sprintf( buf, "%s (%.2f%%)", TimeToString( ztime - ctime ), double( ztime - ctime ) / ztime * 100 ); + ImGui::ProgressBar( double( ztime - ctime ) * rztime, ImVec2( -1, ty ), buf ); ImGui::NextColumn(); + for( size_t i=0; i( cgr.v.size() ); + auto cti = std::make_unique( cgr.v.size() ); + for( size_t i=0; i ctt[rhs]; } ); + + for( size_t i=0; i( children.size() ); + auto cti = std::make_unique( children.size() ); + uint64_t ctime = 0; + for( size_t i=0; i ctt[rhs]; } ); + + ImGui::Columns( 2 ); + ImGui::TextColored( ImVec4( 1.0f, 1.0f, 0.4f, 1.0f ), "Self time" ); + ImGui::NextColumn(); + char buf[128]; + sprintf( buf, "%s (%.2f%%)", TimeToString( ztime - ctime ), double( ztime - ctime ) / ztime * 100 ); + ImGui::ProgressBar( double( ztime - ctime ) * rztime, ImVec2( -1, ty ), buf ); + ImGui::NextColumn(); + for( size_t i=0; i