mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Optimize UpdateLockCount.
This commit is contained in:
parent
c1a79c0622
commit
19db1a3f1f
@ -1165,15 +1165,30 @@ void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev, uint64_t thread )
|
|||||||
void View::UpdateLockCount( LockMap& lockmap, size_t pos )
|
void View::UpdateLockCount( LockMap& lockmap, size_t pos )
|
||||||
{
|
{
|
||||||
auto& timeline = lockmap.timeline;
|
auto& timeline = lockmap.timeline;
|
||||||
uint8_t lockingThread = pos == 0 ? 0 : timeline[pos-1]->lockingThread;
|
uint8_t lockingThread;
|
||||||
uint8_t lockCount = pos == 0 ? 0 : timeline[pos-1]->lockCount;
|
uint8_t lockCount;
|
||||||
uint64_t waitList = pos == 0 ? 0 : timeline[pos-1]->waitList;
|
uint64_t waitList;
|
||||||
|
|
||||||
|
if( pos == 0 )
|
||||||
|
{
|
||||||
|
lockingThread = 0;
|
||||||
|
lockCount = 0;
|
||||||
|
waitList = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto tl = timeline[pos-1];
|
||||||
|
lockingThread = tl->lockingThread;
|
||||||
|
lockCount = tl->lockCount;
|
||||||
|
waitList = tl->waitList;
|
||||||
|
}
|
||||||
const auto end = timeline.size();
|
const auto end = timeline.size();
|
||||||
|
|
||||||
while( pos != end )
|
while( pos != end )
|
||||||
{
|
{
|
||||||
const auto tbit = uint64_t( 1 ) << timeline[pos]->thread;
|
const auto tl = timeline[pos];
|
||||||
switch( (LockEvent::Type)timeline[pos]->type )
|
const auto tbit = uint64_t( 1 ) << tl->thread;
|
||||||
|
switch( (LockEvent::Type)tl->type )
|
||||||
{
|
{
|
||||||
case LockEvent::Type::Wait:
|
case LockEvent::Type::Wait:
|
||||||
waitList |= tbit;
|
waitList |= tbit;
|
||||||
@ -1182,7 +1197,7 @@ void View::UpdateLockCount( LockMap& lockmap, size_t pos )
|
|||||||
assert( lockCount < std::numeric_limits<uint8_t>::max() );
|
assert( lockCount < std::numeric_limits<uint8_t>::max() );
|
||||||
assert( ( waitList | tbit ) != 0 );
|
assert( ( waitList | tbit ) != 0 );
|
||||||
waitList &= ~tbit;
|
waitList &= ~tbit;
|
||||||
lockingThread = timeline[pos]->thread;
|
lockingThread = tl->thread;
|
||||||
lockCount++;
|
lockCount++;
|
||||||
break;
|
break;
|
||||||
case LockEvent::Type::Release:
|
case LockEvent::Type::Release:
|
||||||
@ -1192,10 +1207,10 @@ void View::UpdateLockCount( LockMap& lockmap, size_t pos )
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
timeline[pos]->lockingThread = lockingThread;
|
tl->lockingThread = lockingThread;
|
||||||
timeline[pos]->waitList = waitList;
|
tl->waitList = waitList;
|
||||||
timeline[pos]->lockCount = lockCount;
|
tl->lockCount = lockCount;
|
||||||
assert( timeline[pos]->lockingThread == lockingThread );
|
assert( tl->lockingThread == lockingThread );
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user