Cache statistics range-limited data.

This commit is contained in:
Bartosz Taudul 2020-11-01 16:24:08 +01:00
parent 87c3796e84
commit a48d540854
2 changed files with 60 additions and 24 deletions

View File

@ -11938,6 +11938,17 @@ void View::DrawStatistics()
if( it->second.total != 0 && it->second.min <= st ) if( it->second.total != 0 && it->second.min <= st )
{ {
if( !filterActive ) if( !filterActive )
{
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 )
{
slzcnt++;
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cit->second.count, cit->second.total, cit->second.selfTotal } );
}
}
else
{ {
size_t cnt = 0; size_t cnt = 0;
int64_t total = 0; int64_t total = 0;
@ -11960,6 +11971,8 @@ void View::DrawStatistics()
slzcnt++; slzcnt++;
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total, selfTotal } ); 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 else
{ {
@ -11967,6 +11980,16 @@ void View::DrawStatistics()
auto& sl = m_worker.GetSourceLocation( it->first ); auto& sl = m_worker.GetSourceLocation( it->first );
auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function ); auto name = m_worker.GetString( sl.name.active ? sl.name : sl.function );
if( m_statisticsFilter.PassFilter( name ) ) 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; size_t cnt = 0;
int64_t total = 0; int64_t total = 0;
@ -11988,6 +12011,8 @@ void View::DrawStatistics()
{ {
srcloc.push_back_no_space_check( SrcLocZonesSlim { it->first, cnt, total, selfTotal } ); 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 };
}
} }
} }
} }

View File

@ -56,6 +56,15 @@ class View
uint64_t count; uint64_t count;
}; };
struct StatisticsCache
{
RangeSlim range;
size_t sourceCount;
size_t count;
int64_t total;
int64_t selfTotal;
};
public: public:
struct VisData struct VisData
{ {
@ -468,6 +477,8 @@ private:
RangeSlim m_setRangePopup; RangeSlim m_setRangePopup;
bool m_setRangePopupOpen = false; bool m_setRangePopupOpen = false;
unordered_flat_map<int16_t, StatisticsCache> m_statCache;
void(*m_cbMainThread)(std::function<void()>); void(*m_cbMainThread)(std::function<void()>);
struct FindZone { struct FindZone {