mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Move samples before groups in "find zone" window
and fix style
This commit is contained in:
parent
0089c832f7
commit
1233b39b69
@ -10698,6 +10698,103 @@ void View::DrawFindZone()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames );
|
SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames );
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if( ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) )
|
||||||
|
{
|
||||||
|
{
|
||||||
|
ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox( ICON_FA_EYE_SLASH " Hide unknown", &m_statHideUnknown );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox( ICON_FA_SITEMAP " Inlines", &m_statSeparateInlines );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox( ICON_FA_AT " Address", &m_statShowAddress );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel ))
|
||||||
|
{
|
||||||
|
m_findZone.samplesCache.scheduleUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_findZone.samplesCache.scheduleUpdate && !m_findZone.scheduleResetMatch )
|
||||||
|
{
|
||||||
|
m_findZone.samplesCache.scheduleUpdate = false;
|
||||||
|
|
||||||
|
m_findZone.samplesCache.timeRange = 0;
|
||||||
|
for( auto& t: m_findZone.samplesCache.threads )
|
||||||
|
{
|
||||||
|
pdqsort_branchless( t.second.begin(), t.second.end(), []( const auto& lhs, const auto& rhs ) { return (*lhs).Start() < (*rhs).Start(); } );
|
||||||
|
|
||||||
|
int64_t prevEnd = 0;
|
||||||
|
for( const auto& it : t.second )
|
||||||
|
{
|
||||||
|
int64_t start = (*it).Start();
|
||||||
|
int64_t end = (*it).End();
|
||||||
|
if( start < prevEnd ) start = prevEnd;
|
||||||
|
if( start < end )
|
||||||
|
{
|
||||||
|
prevEnd = end;
|
||||||
|
m_findZone.samplesCache.timeRange += end - start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& symMap = m_worker.GetSymbolMap();
|
||||||
|
m_findZone.samplesCache.counts.clear();
|
||||||
|
m_findZone.samplesCache.counts.reserve( symMap.size() );
|
||||||
|
|
||||||
|
for( auto& v : symMap )
|
||||||
|
{
|
||||||
|
bool pass = ( m_statShowKernel || ( v.first >> 63 ) == 0 );
|
||||||
|
if( !pass && v.second.size.Val() == 0 )
|
||||||
|
{
|
||||||
|
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
|
||||||
|
if( parentAddr != 0 )
|
||||||
|
{
|
||||||
|
auto pit = symMap.find( parentAddr );
|
||||||
|
if( pit != symMap.end() )
|
||||||
|
{
|
||||||
|
pass = ( m_statShowKernel || ( parentAddr >> 63 ) == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !pass ) continue;
|
||||||
|
|
||||||
|
auto samples = m_worker.GetSamplesForSymbol( v.first );
|
||||||
|
if( !samples ) continue;
|
||||||
|
|
||||||
|
uint32_t count = 0;
|
||||||
|
for( auto it: *samples )
|
||||||
|
{
|
||||||
|
const auto time = it.time.Val();
|
||||||
|
const auto& zones = m_findZone.samplesCache.threads[it.thread];
|
||||||
|
auto z = std::lower_bound( zones.begin(), zones.end(), time, [] ( const auto& l, const auto& r ) { return l->Start() < r; } );
|
||||||
|
if( z == zones.end() ) continue;
|
||||||
|
if( z != zones.begin() ) --z;
|
||||||
|
if( time >= (*z)->Start() && time < (*z)->End() )
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if( count > 0 ) m_findZone.samplesCache.counts.push_back_no_space_check( SymList { v.first, 0, count } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<SymList> data;
|
||||||
|
data.reserve( m_findZone.samplesCache.counts.size() );
|
||||||
|
for( auto it: m_findZone.samplesCache.counts ) data.push_back_no_space_check( it );
|
||||||
|
DrawSamplesStatistics( data, m_findZone.samplesCache.timeRange, AccumulationMode::SelfOnly );
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
ImGui::TextUnformatted( "Found zones:" );
|
ImGui::TextUnformatted( "Found zones:" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
DrawHelpMarker( "Left click to highlight entry." );
|
DrawHelpMarker( "Left click to highlight entry." );
|
||||||
@ -10856,12 +10953,13 @@ void View::DrawFindZone()
|
|||||||
group->time += timespan;
|
group->time += timespan;
|
||||||
group->zones.push_back_non_empty( ev.Zone() );
|
group->zones.push_back_non_empty( ev.Zone() );
|
||||||
|
|
||||||
if (lastTid != ev.Thread()) {
|
if( lastTid != ev.Thread() )
|
||||||
|
{
|
||||||
lastTid = ev.Thread();
|
lastTid = ev.Thread();
|
||||||
threadZones = &m_findZone.samplesCache.threads[lastTid];
|
threadZones = &m_findZone.samplesCache.threads[lastTid];
|
||||||
threadZones->reserve( 1024 );
|
threadZones->reserve( 1024 );
|
||||||
}
|
}
|
||||||
threadZones->push_back_non_empty(ev.Zone());
|
threadZones->push_back_non_empty( ev.Zone() );
|
||||||
m_findZone.samplesCache.scheduleUpdate = true;
|
m_findZone.samplesCache.scheduleUpdate = true;
|
||||||
}
|
}
|
||||||
m_findZone.processed = zptr - zones.data();
|
m_findZone.processed = zptr - zones.data();
|
||||||
@ -11081,97 +11179,6 @@ void View::DrawFindZone()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) )
|
|
||||||
{
|
|
||||||
{
|
|
||||||
ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Checkbox( ICON_FA_EYE_SLASH " Hide unknown", &m_statHideUnknown );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Checkbox( ICON_FA_SITEMAP " Inlines", &m_statSeparateInlines );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Checkbox( ICON_FA_AT " Address", &m_statShowAddress );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Spacing();
|
|
||||||
ImGui::SameLine();
|
|
||||||
if( ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel ))
|
|
||||||
{
|
|
||||||
m_findZone.samplesCache.scheduleUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_findZone.samplesCache.scheduleUpdate && !m_findZone.scheduleResetMatch) {
|
|
||||||
m_findZone.samplesCache.scheduleUpdate = false;
|
|
||||||
|
|
||||||
m_findZone.samplesCache.timeRange = 0;
|
|
||||||
for (auto& t: m_findZone.samplesCache.threads) {
|
|
||||||
pdqsort_branchless( t.second.begin(), t.second.end(), []( const auto& lhs, const auto& rhs ) { return (*lhs).Start() < (*rhs).Start(); } );
|
|
||||||
int64_t prevEnd = 0;
|
|
||||||
for (const auto& it : t.second)
|
|
||||||
{
|
|
||||||
int64_t start = (*it).Start();
|
|
||||||
int64_t end = (*it).End();
|
|
||||||
if (start < prevEnd) start = prevEnd;
|
|
||||||
if (start < end) {
|
|
||||||
prevEnd = end;
|
|
||||||
m_findZone.samplesCache.timeRange += end - start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& symMap = m_worker.GetSymbolMap();
|
|
||||||
m_findZone.samplesCache.counts.clear();
|
|
||||||
m_findZone.samplesCache.counts.reserve( symMap.size() );
|
|
||||||
|
|
||||||
for( auto& v : symMap )
|
|
||||||
{
|
|
||||||
bool pass = ( m_statShowKernel || ( v.first >> 63 ) == 0 );
|
|
||||||
if( !pass && v.second.size.Val() == 0 )
|
|
||||||
{
|
|
||||||
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
|
|
||||||
if( parentAddr != 0 )
|
|
||||||
{
|
|
||||||
auto pit = symMap.find( parentAddr );
|
|
||||||
if( pit != symMap.end() )
|
|
||||||
{
|
|
||||||
pass = ( m_statShowKernel || ( parentAddr >> 63 ) == 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!pass) continue;
|
|
||||||
|
|
||||||
auto samples = m_worker.GetSamplesForSymbol( v.first );
|
|
||||||
if( !samples ) continue;
|
|
||||||
|
|
||||||
uint32_t count = 0;
|
|
||||||
for (auto it: *samples) {
|
|
||||||
const auto time = it.time.Val();
|
|
||||||
const auto& zones = m_findZone.samplesCache.threads[it.thread];
|
|
||||||
auto z = std::lower_bound( zones.begin(), zones.end(), time, [] ( const auto& l, const auto& r ) { return l->Start() < r; } );
|
|
||||||
if( z == zones.end() ) continue;
|
|
||||||
if (z != zones.begin()) --z;
|
|
||||||
if (time >= (*z)->Start() && time < (*z)->End())
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count > 0)
|
|
||||||
m_findZone.samplesCache.counts.push_back_no_space_check( SymList { v.first, 0, count } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<SymList> data;
|
|
||||||
data.reserve(m_findZone.samplesCache.counts.size());
|
|
||||||
for (auto it: m_findZone.samplesCache.counts) data.push_back_no_space_check(it);
|
|
||||||
DrawSamplesStatistics(data, m_findZone.samplesCache.timeRange, AccumulationMode::SelfOnly);
|
|
||||||
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user