mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Cache statistics range-limited data.
This commit is contained in:
parent
87c3796e84
commit
a48d540854
@ -11939,34 +11939,16 @@ void View::DrawStatistics()
|
||||
{
|
||||
if( !filterActive )
|
||||
{
|
||||
size_t cnt = 0;
|
||||
int64_t total = 0;
|
||||
int64_t selfTotal = 0;
|
||||
for( auto& v : it->second.zones )
|
||||
auto cit = m_statCache.find( it->first );
|
||||
if( cit != m_statCache.end() && cit->second.range == m_statRange && cit->second.sourceCount == it->second.zones.size() )
|
||||
{
|
||||
auto& z = *v.Zone();
|
||||
const auto start = z.Start();
|
||||
const auto end = z.End();
|
||||
if( start >= min && end <= max )
|
||||
if( cit->second.count != 0 )
|
||||
{
|
||||
const auto zt = end - start;
|
||||
total += zt;
|
||||
if( m_statSelf ) selfTotal += zt - GetZoneChildTimeFast( z );
|
||||
cnt++;
|
||||
slzcnt++;
|
||||
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total, cit->second.selfTotal } );
|
||||
}
|
||||
}
|
||||
if( cnt != 0 )
|
||||
{
|
||||
slzcnt++;
|
||||
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total, selfTotal } );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slzcnt++;
|
||||
auto& sl = m_worker.GetSourceLocation( it->first );
|
||||
auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function );
|
||||
if( m_statisticsFilter.PassFilter( name ) )
|
||||
else
|
||||
{
|
||||
size_t cnt = 0;
|
||||
int64_t total = 0;
|
||||
@ -11986,8 +11968,51 @@ void View::DrawStatistics()
|
||||
}
|
||||
if( cnt != 0 )
|
||||
{
|
||||
slzcnt++;
|
||||
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total, selfTotal } );
|
||||
}
|
||||
m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, it->second.zones.size(), cnt, total, selfTotal };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slzcnt++;
|
||||
auto& sl = m_worker.GetSourceLocation( it->first );
|
||||
auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function );
|
||||
if( m_statisticsFilter.PassFilter( name ) )
|
||||
{
|
||||
auto cit = m_statCache.find( it->first );
|
||||
if( cit != m_statCache.end() && cit->second.range == m_statRange && cit->second.sourceCount == it->second.zones.size() )
|
||||
{
|
||||
if( cit->second.count != 0 )
|
||||
{
|
||||
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total, cit->second.selfTotal } );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t cnt = 0;
|
||||
int64_t total = 0;
|
||||
int64_t selfTotal = 0;
|
||||
for( auto& v : it->second.zones )
|
||||
{
|
||||
auto& z = *v.Zone();
|
||||
const auto start = z.Start();
|
||||
const auto end = z.End();
|
||||
if( start >= min && end <= max )
|
||||
{
|
||||
const auto zt = end - start;
|
||||
total += zt;
|
||||
if( m_statSelf ) selfTotal += zt - GetZoneChildTimeFast( z );
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
if( cnt != 0 )
|
||||
{
|
||||
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total, selfTotal } );
|
||||
}
|
||||
m_statCache[it->first] = StatisticsCache { RangeSlim { m_statRange.min, m_statRange.max, m_statRange.active }, it->second.zones.size(), cnt, total, selfTotal };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,15 @@ class View
|
||||
uint64_t count;
|
||||
};
|
||||
|
||||
struct StatisticsCache
|
||||
{
|
||||
RangeSlim range;
|
||||
size_t sourceCount;
|
||||
size_t count;
|
||||
int64_t total;
|
||||
int64_t selfTotal;
|
||||
};
|
||||
|
||||
public:
|
||||
struct VisData
|
||||
{
|
||||
@ -468,6 +477,8 @@ private:
|
||||
RangeSlim m_setRangePopup;
|
||||
bool m_setRangePopupOpen = false;
|
||||
|
||||
unordered_flat_map<int16_t, StatisticsCache> m_statCache;
|
||||
|
||||
void(*m_cbMainThread)(std::function<void()>);
|
||||
|
||||
struct FindZone {
|
||||
|
Loading…
Reference in New Issue
Block a user