mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Cache samples statistics in the "find zone" window
This commit is contained in:
parent
ed42c2388c
commit
0089c832f7
@ -10862,6 +10862,7 @@ void View::DrawFindZone()
|
||||
threadZones->reserve( 1024 );
|
||||
}
|
||||
threadZones->push_back_non_empty(ev.Zone());
|
||||
m_findZone.samplesCache.scheduleUpdate = true;
|
||||
}
|
||||
m_findZone.processed = zptr - zones.data();
|
||||
|
||||
@ -11099,16 +11100,35 @@ void View::DrawFindZone()
|
||||
ImGui::SameLine();
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel );
|
||||
if( ImGui::Checkbox( ICON_FA_HAT_WIZARD " Include kernel", &m_statShowKernel ))
|
||||
{
|
||||
m_findZone.samplesCache.scheduleUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& t: m_findZone.threads) {
|
||||
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();
|
||||
Vector<SymList> data;
|
||||
data.reserve( symMap.size() );
|
||||
m_findZone.samplesCache.counts.clear();
|
||||
m_findZone.samplesCache.counts.reserve( symMap.size() );
|
||||
|
||||
for( auto& v : symMap )
|
||||
{
|
||||
bool pass = ( m_statShowKernel || ( v.first >> 63 ) == 0 );
|
||||
@ -11132,7 +11152,7 @@ void View::DrawFindZone()
|
||||
uint32_t count = 0;
|
||||
for (auto it: *samples) {
|
||||
const auto time = it.time.Val();
|
||||
const auto& zones = m_findZone.threads[it.thread];
|
||||
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;
|
||||
@ -11140,9 +11160,15 @@ void View::DrawFindZone()
|
||||
count++;
|
||||
}
|
||||
if (count > 0)
|
||||
data.push_back_no_space_check( SymList { v.first, 0, count } );
|
||||
m_findZone.samplesCache.counts.push_back_no_space_check( SymList { v.first, 0, count } );
|
||||
}
|
||||
DrawSamplesStatistics(data, m_worker.GetLastTime(), AccumulationMode::SelfOnly);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,6 @@ private:
|
||||
bool ignoreCase = false;
|
||||
std::vector<int16_t> match;
|
||||
unordered_flat_map<uint64_t, Group> groups;
|
||||
unordered_flat_map<uint16_t, Vector<short_ptr<ZoneEvent>> > threads;
|
||||
size_t processed;
|
||||
uint16_t groupId;
|
||||
int selMatch = 0;
|
||||
@ -563,6 +562,13 @@ private:
|
||||
ptrdiff_t distEnd;
|
||||
} binCache;
|
||||
|
||||
struct {
|
||||
unordered_flat_map<uint16_t, Vector<short_ptr<ZoneEvent>> > threads;
|
||||
Vector<SymList> counts;
|
||||
int64_t timeRange = 0;
|
||||
bool scheduleUpdate = false;
|
||||
} samplesCache;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
ResetMatch();
|
||||
@ -588,7 +594,8 @@ private:
|
||||
{
|
||||
ResetSelection();
|
||||
groups.clear();
|
||||
threads.clear();
|
||||
samplesCache.threads.clear();
|
||||
samplesCache.counts.clear();
|
||||
processed = 0;
|
||||
groupId = 0;
|
||||
selCs = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user