mirror of
https://github.com/wolfpld/tracy
synced 2025-05-08 07:53:52 +00:00
Time distribution may now only include running time.
This commit is contained in:
parent
6ced346e08
commit
0a358ac1f0
@ -5252,20 +5252,20 @@ struct ZoneTimeData
|
||||
uint64_t count;
|
||||
};
|
||||
|
||||
void 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, Worker& worker )
|
||||
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 );
|
||||
const auto& children = worker.GetZoneChildren( zone.Child() );
|
||||
const auto& children = m_worker.GetZoneChildren( zone.Child() );
|
||||
|
||||
for( auto& child : children )
|
||||
{
|
||||
const auto t = worker.GetZoneEnd( *child ) - child->Start();
|
||||
const auto t = m_worker.GetZoneEnd( *child ) - child->Start();
|
||||
zit->second.time -= t;
|
||||
}
|
||||
for( auto& child : children )
|
||||
{
|
||||
const auto srcloc = child->SrcLoc();
|
||||
const auto t = worker.GetZoneEnd( *child ) - child->Start();
|
||||
const auto t = m_worker.GetZoneEnd( *child ) - child->Start();
|
||||
auto it = data.find( srcloc );
|
||||
if( it == data.end() )
|
||||
{
|
||||
@ -5276,7 +5276,41 @@ void CalcZoneTimeData( flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>& d
|
||||
it->second.time += t;
|
||||
it->second.count++;
|
||||
}
|
||||
if( child->Child() >= 0 ) CalcZoneTimeData( data, it, *child, worker );
|
||||
if( child->Child() >= 0 ) CalcZoneTimeData( data, it, *child );
|
||||
}
|
||||
}
|
||||
|
||||
void View::CalcZoneTimeData( const ContextSwitch* ctx, 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 );
|
||||
const auto& children = m_worker.GetZoneChildren( zone.Child() );
|
||||
|
||||
for( auto& child : children )
|
||||
{
|
||||
int64_t t;
|
||||
uint64_t cnt;
|
||||
const auto res = GetZoneRunningTime( ctx, *child, t, cnt );
|
||||
assert( res );
|
||||
zit->second.time -= t;
|
||||
}
|
||||
for( auto& child : children )
|
||||
{
|
||||
const auto srcloc = child->SrcLoc();
|
||||
int64_t t;
|
||||
uint64_t cnt;
|
||||
const auto res = GetZoneRunningTime( ctx, *child, t, cnt );
|
||||
assert( res );
|
||||
auto it = data.find( srcloc );
|
||||
if( it == data.end() )
|
||||
{
|
||||
it = data.emplace( srcloc, ZoneTimeData { t, 1 } ).first;
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second.time += t;
|
||||
it->second.count++;
|
||||
}
|
||||
if( child->Child() >= 0 ) CalcZoneTimeData( ctx, data, it, *child );
|
||||
}
|
||||
}
|
||||
|
||||
@ -6084,9 +6118,37 @@ void View::DrawZoneInfoWindow()
|
||||
bool expand = ImGui::TreeNode( "Time distribution" );
|
||||
if( expand )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if( ctx )
|
||||
{
|
||||
SmallCheckbox( "Running time", &m_timeDist.runningTime );
|
||||
}
|
||||
flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>> data;
|
||||
float fztime;
|
||||
if( m_timeDist.runningTime )
|
||||
{
|
||||
assert( ctx );
|
||||
int64_t time;
|
||||
uint64_t cnt;
|
||||
if( !GetZoneRunningTime( ctx, ev, time, cnt ) )
|
||||
{
|
||||
TextDisabledUnformatted( "Incomplete context switch data." );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = data.emplace( ev.SrcLoc(), ZoneTimeData{ time, 1 } ).first;
|
||||
CalcZoneTimeData( ctx, data, it, ev );
|
||||
}
|
||||
fztime = 100.f / time;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = data.emplace( ev.SrcLoc(), ZoneTimeData{ ztime, 1 } ).first;
|
||||
CalcZoneTimeData( data, it, ev, m_worker );
|
||||
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;
|
||||
vec.reserve( data.size() );
|
||||
for( auto it = data.cbegin(); it != data.cend(); ++it ) vec.emplace_back( it );
|
||||
@ -6122,7 +6184,6 @@ void View::DrawZoneInfoWindow()
|
||||
assert( false );
|
||||
break;
|
||||
}
|
||||
const auto fztime = 100.f / ztime;
|
||||
for( auto& v : vec )
|
||||
{
|
||||
ImGui::TextUnformatted( m_worker.GetZoneName( m_worker.GetSourceLocation( v->first ) ) );
|
||||
@ -6137,6 +6198,7 @@ void View::DrawZoneInfoWindow()
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
ImGui::EndColumns();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ struct MemoryPage;
|
||||
struct QueueItem;
|
||||
class FileRead;
|
||||
class TextEditor;
|
||||
struct ZoneTimeData;
|
||||
|
||||
class View
|
||||
{
|
||||
@ -208,6 +209,9 @@ private:
|
||||
int64_t GetZoneSelfTime( const GpuEvent& zone );
|
||||
bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt );
|
||||
|
||||
void 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 CalcZoneTimeData( const ContextSwitch* ctx, 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 SetPlaybackFrame( uint32_t idx );
|
||||
|
||||
flat_hash_map<const void*, VisData, nohash<const void*>> m_visData;
|
||||
@ -565,6 +569,7 @@ private:
|
||||
struct TimeDistribution {
|
||||
enum class SortBy : int { Count, Time, Mtpc };
|
||||
SortBy sortBy = SortBy::Time;
|
||||
bool runningTime = false;
|
||||
} m_timeDist;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user