mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +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;
|
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 );
|
assert( zone.Child() >= 0 );
|
||||||
const auto& children = worker.GetZoneChildren( zone.Child() );
|
const auto& children = m_worker.GetZoneChildren( zone.Child() );
|
||||||
|
|
||||||
for( auto& child : children )
|
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;
|
zit->second.time -= t;
|
||||||
}
|
}
|
||||||
for( auto& child : children )
|
for( auto& child : children )
|
||||||
{
|
{
|
||||||
const auto srcloc = child->SrcLoc();
|
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 );
|
auto it = data.find( srcloc );
|
||||||
if( it == data.end() )
|
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.time += t;
|
||||||
it->second.count++;
|
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" );
|
bool expand = ImGui::TreeNode( "Time distribution" );
|
||||||
if( expand )
|
if( expand )
|
||||||
{
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
if( ctx )
|
||||||
|
{
|
||||||
|
SmallCheckbox( "Running time", &m_timeDist.runningTime );
|
||||||
|
}
|
||||||
flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>> data;
|
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;
|
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;
|
std::vector<flat_hash_map<int16_t, ZoneTimeData, nohash<uint16_t>>::const_iterator> vec;
|
||||||
vec.reserve( data.size() );
|
vec.reserve( data.size() );
|
||||||
for( auto it = data.cbegin(); it != data.cend(); ++it ) vec.emplace_back( it );
|
for( auto it = data.cbegin(); it != data.cend(); ++it ) vec.emplace_back( it );
|
||||||
@ -6122,7 +6184,6 @@ void View::DrawZoneInfoWindow()
|
|||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const auto fztime = 100.f / ztime;
|
|
||||||
for( auto& v : vec )
|
for( auto& v : vec )
|
||||||
{
|
{
|
||||||
ImGui::TextUnformatted( m_worker.GetZoneName( m_worker.GetSourceLocation( v->first ) ) );
|
ImGui::TextUnformatted( m_worker.GetZoneName( m_worker.GetSourceLocation( v->first ) ) );
|
||||||
@ -6137,6 +6198,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
}
|
}
|
||||||
ImGui::EndColumns();
|
ImGui::EndColumns();
|
||||||
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ struct MemoryPage;
|
|||||||
struct QueueItem;
|
struct QueueItem;
|
||||||
class FileRead;
|
class FileRead;
|
||||||
class TextEditor;
|
class TextEditor;
|
||||||
|
struct ZoneTimeData;
|
||||||
|
|
||||||
class View
|
class View
|
||||||
{
|
{
|
||||||
@ -208,6 +209,9 @@ private:
|
|||||||
int64_t GetZoneSelfTime( const GpuEvent& zone );
|
int64_t GetZoneSelfTime( const GpuEvent& zone );
|
||||||
bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt );
|
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 );
|
void SetPlaybackFrame( uint32_t idx );
|
||||||
|
|
||||||
flat_hash_map<const void*, VisData, nohash<const void*>> m_visData;
|
flat_hash_map<const void*, VisData, nohash<const void*>> m_visData;
|
||||||
@ -565,6 +569,7 @@ private:
|
|||||||
struct TimeDistribution {
|
struct TimeDistribution {
|
||||||
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;
|
||||||
} m_timeDist;
|
} m_timeDist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user