mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Track number of held locks.
This commit is contained in:
parent
39bb9a3ad1
commit
4c8e9f7d5d
@ -41,6 +41,7 @@ struct LockEvent
|
|||||||
|
|
||||||
int64_t time;
|
int64_t time;
|
||||||
uint64_t thread;
|
uint64_t thread;
|
||||||
|
uint8_t lockCount;
|
||||||
Type type;
|
Type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -681,11 +681,38 @@ void View::InsertLockEvent( Vector<LockEvent*>& timeline, LockEvent* lev )
|
|||||||
if( timeline.empty() || timeline.back()->time < lev->time )
|
if( timeline.empty() || timeline.back()->time < lev->time )
|
||||||
{
|
{
|
||||||
timeline.push_back( lev );
|
timeline.push_back( lev );
|
||||||
|
UpdateLockCount( timeline, timeline.size() - 1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto it = std::lower_bound( timeline.begin(), timeline.end(), lev->time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );
|
auto it = std::lower_bound( timeline.begin(), timeline.end(), lev->time, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } );
|
||||||
timeline.insert( it, lev );
|
it = timeline.insert( it, lev );
|
||||||
|
UpdateLockCount( timeline, std::distance( timeline.begin(), it ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void View::UpdateLockCount( Vector<LockEvent*>& timeline, size_t pos )
|
||||||
|
{
|
||||||
|
uint8_t count = pos == 0 ? 0 : timeline[pos-1]->lockCount;
|
||||||
|
const auto end = timeline.size();
|
||||||
|
|
||||||
|
while( pos != end )
|
||||||
|
{
|
||||||
|
switch( timeline[pos]->type )
|
||||||
|
{
|
||||||
|
case LockEvent::Type::Obtain:
|
||||||
|
assert( count < std::numeric_limits<uint8_t>::max() );
|
||||||
|
count++;
|
||||||
|
break;
|
||||||
|
case LockEvent::Type::Release:
|
||||||
|
assert( count > 0 );
|
||||||
|
count--;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timeline[pos]->lockCount = count;
|
||||||
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ private:
|
|||||||
void InsertZone( Event* zone, Event* parent, Vector<Event*>& vec );
|
void InsertZone( Event* zone, Event* parent, Vector<Event*>& vec );
|
||||||
|
|
||||||
void InsertLockEvent( Vector<LockEvent*>& timeline, LockEvent* lev );
|
void InsertLockEvent( Vector<LockEvent*>& timeline, LockEvent* lev );
|
||||||
|
void UpdateLockCount( Vector<LockEvent*>& timeline, size_t pos );
|
||||||
|
|
||||||
uint64_t GetFrameTime( size_t idx ) const;
|
uint64_t GetFrameTime( size_t idx ) const;
|
||||||
uint64_t GetFrameBegin( size_t idx ) const;
|
uint64_t GetFrameBegin( size_t idx ) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user