mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Cache zone time distribution data.
This commit is contained in:
parent
4d761def61
commit
ccdc102d5a
@ -5403,12 +5403,6 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, B
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ZoneTimeData
|
|
||||||
{
|
|
||||||
int64_t time;
|
|
||||||
uint64_t count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void View::CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
|
void View::CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& data, flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::iterator zit, const ZoneEvent& zone )
|
||||||
{
|
{
|
||||||
assert( zone.Child() >= 0 );
|
assert( zone.Child() >= 0 );
|
||||||
@ -6278,37 +6272,41 @@ void View::DrawZoneInfoWindow()
|
|||||||
if( ctx )
|
if( ctx )
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
SmallCheckbox( "Running time", &m_timeDist.runningTime );
|
if( SmallCheckbox( "Running time", &m_timeDist.runningTime ) ) m_timeDist.dataValidFor = nullptr;
|
||||||
}
|
}
|
||||||
flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>> data;
|
if( m_timeDist.dataValidFor != &ev )
|
||||||
float fztime;
|
|
||||||
if( m_timeDist.runningTime )
|
|
||||||
{
|
{
|
||||||
assert( ctx );
|
m_timeDist.data.clear();
|
||||||
int64_t time;
|
if( ev.End() >= 0 ) m_timeDist.dataValidFor = &ev;
|
||||||
uint64_t cnt;
|
|
||||||
if( !GetZoneRunningTime( ctx, ev, time, cnt ) )
|
if( m_timeDist.runningTime )
|
||||||
{
|
{
|
||||||
TextDisabledUnformatted( "Incomplete context switch data." );
|
assert( ctx );
|
||||||
|
int64_t time;
|
||||||
|
uint64_t cnt;
|
||||||
|
if( !GetZoneRunningTime( ctx, ev, time, cnt ) )
|
||||||
|
{
|
||||||
|
TextDisabledUnformatted( "Incomplete context switch data." );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto it = m_timeDist.data.emplace( ev.SrcLoc(), ZoneTimeData{ time, 1 } ).first;
|
||||||
|
CalcZoneTimeData( ctx, m_timeDist.data, it, ev );
|
||||||
|
}
|
||||||
|
m_timeDist.fztime = 100.f / time;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto it = data.emplace( ev.SrcLoc(), ZoneTimeData{ time, 1 } ).first;
|
auto it = m_timeDist.data.emplace( ev.SrcLoc(), ZoneTimeData{ ztime, 1 } ).first;
|
||||||
CalcZoneTimeData( ctx, data, it, ev );
|
CalcZoneTimeData( m_timeDist.data, it, ev );
|
||||||
|
m_timeDist.fztime = 100.f / ztime;
|
||||||
}
|
}
|
||||||
fztime = 100.f / time;
|
|
||||||
}
|
}
|
||||||
else
|
if( !m_timeDist.data.empty() )
|
||||||
{
|
|
||||||
auto it = data.emplace( ev.SrcLoc(), ZoneTimeData{ ztime, 1 } ).first;
|
|
||||||
CalcZoneTimeData( data, it, ev );
|
|
||||||
fztime = 100.f / ztime;
|
|
||||||
}
|
|
||||||
if( !data.empty() )
|
|
||||||
{
|
{
|
||||||
std::vector<flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::const_iterator> vec;
|
std::vector<flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::const_iterator> vec;
|
||||||
vec.reserve( data.size() );
|
vec.reserve( m_timeDist.data.size() );
|
||||||
for( auto it = data.cbegin(); it != data.cend(); ++it ) vec.emplace_back( it );
|
for( auto it = m_timeDist.data.cbegin(); it != m_timeDist.data.cend(); ++it ) vec.emplace_back( it );
|
||||||
static bool widthSet = false;
|
static bool widthSet = false;
|
||||||
ImGui::Columns( 3 );
|
ImGui::Columns( 3 );
|
||||||
if( !widthSet )
|
if( !widthSet )
|
||||||
@ -6349,7 +6347,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::TextUnformatted( TimeToString( v->second.time ) );
|
ImGui::TextUnformatted( TimeToString( v->second.time ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "(%.2f%%)", v->second.time * fztime );
|
ImGui::TextDisabled( "(%.2f%%)", v->second.time * m_timeDist.fztime );
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
ImGui::TextUnformatted( TimeToString( v->second.time / v->second.count ) );
|
ImGui::TextUnformatted( TimeToString( v->second.time / v->second.count ) );
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|||||||
@ -47,6 +47,12 @@ class View
|
|||||||
int64_t end;
|
int64_t end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ZoneTimeData
|
||||||
|
{
|
||||||
|
int64_t time;
|
||||||
|
uint64_t count;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct VisData
|
struct VisData
|
||||||
{
|
{
|
||||||
@ -575,6 +581,9 @@ private:
|
|||||||
enum class SortBy : int { Count, Time, Mtpc };
|
enum class SortBy : int { Count, Time, Mtpc };
|
||||||
SortBy sortBy = SortBy::Time;
|
SortBy sortBy = SortBy::Time;
|
||||||
bool runningTime = false;
|
bool runningTime = false;
|
||||||
|
flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>> data;
|
||||||
|
const ZoneEvent* dataValidFor = nullptr;
|
||||||
|
float fztime;
|
||||||
} m_timeDist;
|
} m_timeDist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user