mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Don't iterate over children to calculate zone self time.
This commit is contained in:
parent
d6a8a8532f
commit
70f1074490
@ -351,6 +351,9 @@ struct ThreadData
|
|||||||
Vector<MessageData*> messages;
|
Vector<MessageData*> messages;
|
||||||
uint32_t nextZoneId;
|
uint32_t nextZoneId;
|
||||||
Vector<uint32_t> zoneIdStack;
|
Vector<uint32_t> zoneIdStack;
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
Vector<int64_t> childTimeStack;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpuCtxThreadData
|
struct GpuCtxThreadData
|
||||||
|
|||||||
@ -2741,6 +2741,10 @@ void Worker::NewZone( ZoneEvent* zone, uint64_t thread )
|
|||||||
|
|
||||||
td->zoneIdStack.push_back( td->nextZoneId );
|
td->zoneIdStack.push_back( td->nextZoneId );
|
||||||
td->nextZoneId = 0;
|
td->nextZoneId = 0;
|
||||||
|
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
td->childTimeStack.push_back( 0 );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time )
|
void Worker::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread, int64_t time )
|
||||||
@ -3481,7 +3485,8 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
auto timeSpan = timeEnd - zone->Start();
|
assert( !td->childTimeStack.empty() );
|
||||||
|
const auto timeSpan = timeEnd - zone->Start();
|
||||||
if( timeSpan > 0 )
|
if( timeSpan > 0 )
|
||||||
{
|
{
|
||||||
auto it = m_data.sourceLocationZones.find( zone->SrcLoc() );
|
auto it = m_data.sourceLocationZones.find( zone->SrcLoc() );
|
||||||
@ -3491,17 +3496,18 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
|||||||
slz.max = std::max( slz.max, timeSpan );
|
slz.max = std::max( slz.max, timeSpan );
|
||||||
slz.total += timeSpan;
|
slz.total += timeSpan;
|
||||||
slz.sumSq += double( timeSpan ) * timeSpan;
|
slz.sumSq += double( timeSpan ) * timeSpan;
|
||||||
if( zone->Child() >= 0 )
|
const auto selfSpan = timeSpan - td->childTimeStack.back_and_pop();
|
||||||
|
slz.selfMin = std::min( slz.selfMin, selfSpan );
|
||||||
|
slz.selfMax = std::max( slz.selfMax, selfSpan );
|
||||||
|
slz.selfTotal += selfSpan;
|
||||||
|
if( !td->childTimeStack.empty() )
|
||||||
{
|
{
|
||||||
for( auto& v : GetZoneChildren( zone->Child() ) )
|
td->childTimeStack.back() += timeSpan;
|
||||||
{
|
|
||||||
const auto childSpan = std::max( int64_t( 0 ), v->End() - v->Start() );
|
|
||||||
timeSpan -= childSpan;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slz.selfMin = std::min( slz.selfMin, timeSpan );
|
else
|
||||||
slz.selfMax = std::max( slz.selfMax, timeSpan );
|
{
|
||||||
slz.selfTotal += timeSpan;
|
td->childTimeStack.pop_back();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user