mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Adapt zone getters to magic vectors.
This commit is contained in:
parent
f8edd3a37b
commit
0c1f3ac16d
@ -13366,6 +13366,19 @@ int View::GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const
|
||||
auto timeline = &td->timeline;
|
||||
int depth = 0;
|
||||
for(;;)
|
||||
{
|
||||
if( timeline->is_magic() )
|
||||
{
|
||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||
if( it != vec->begin() ) --it;
|
||||
assert( !( zone.End() >= 0 && it->Start() > zone.End() ) );
|
||||
if( it == &zone ) return depth;
|
||||
assert( it->Child() >= 0 );
|
||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||
depth++;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||
if( it != timeline->begin() ) --it;
|
||||
@ -13375,6 +13388,7 @@ int View::GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const
|
||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
||||
@ -13385,6 +13399,19 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
||||
const Vector<short_ptr<ZoneEvent>>* timeline = &thread->timeline;
|
||||
if( timeline->empty() ) continue;
|
||||
for(;;)
|
||||
{
|
||||
if( timeline->is_magic() )
|
||||
{
|
||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||
if( it != vec->begin() ) --it;
|
||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
||||
if( it == &zone ) return parent;
|
||||
if( it->Child() < 0 ) break;
|
||||
parent = it;
|
||||
timeline = &m_worker.GetZoneChildren( parent->Child() );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||
if( it != timeline->begin() ) --it;
|
||||
@ -13395,6 +13422,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
||||
timeline = &m_worker.GetZoneChildren( parent->Child() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -13405,6 +13433,19 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) cons
|
||||
const Vector<short_ptr<ZoneEvent>>* timeline = &thread->timeline;
|
||||
if( timeline->empty() ) return nullptr;
|
||||
for(;;)
|
||||
{
|
||||
if( timeline->is_magic() )
|
||||
{
|
||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||
if( it != vec->begin() ) --it;
|
||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
||||
if( it == &zone ) return parent;
|
||||
if( it->Child() < 0 ) break;
|
||||
parent = it;
|
||||
timeline = &m_worker.GetZoneChildren( parent->Child() );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||
if( it != timeline->begin() ) --it;
|
||||
@ -13414,6 +13455,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) cons
|
||||
parent = *it;
|
||||
timeline = &m_worker.GetZoneChildren( parent->Child() );
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -13448,6 +13490,18 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const
|
||||
const Vector<short_ptr<ZoneEvent>>* timeline = &thread->timeline;
|
||||
if( timeline->empty() ) continue;
|
||||
for(;;)
|
||||
{
|
||||
if( timeline->is_magic() )
|
||||
{
|
||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||
if( it != vec->begin() ) --it;
|
||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
||||
if( it == &zone ) return thread;
|
||||
if( it->Child() < 0 ) break;
|
||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||
if( it != timeline->begin() ) --it;
|
||||
@ -13457,6 +13511,7 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const
|
||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -13533,6 +13588,18 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
|
||||
if( timeline->empty() ) return nullptr;
|
||||
const ZoneEvent* ret = nullptr;
|
||||
for(;;)
|
||||
{
|
||||
if( timeline->is_magic() )
|
||||
{
|
||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||
auto it = std::upper_bound( vec->begin(), vec->end(), time, [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||
if( it != vec->begin() ) --it;
|
||||
if( it->Start() > time || ( it->End() >= 0 && it->End() < time ) ) return ret;
|
||||
ret = it;
|
||||
if( it->Child() < 0 ) return ret;
|
||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), time, [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||
if( it != timeline->begin() ) --it;
|
||||
@ -13541,6 +13608,7 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
|
||||
if( (*it)->Child() < 0 ) return ret;
|
||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
@ -13644,12 +13712,25 @@ int64_t View::GetZoneChildTime( const ZoneEvent& zone )
|
||||
int64_t time = 0;
|
||||
if( zone.Child() >= 0 )
|
||||
{
|
||||
for( auto& v : m_worker.GetZoneChildren( zone.Child() ) )
|
||||
auto& children = m_worker.GetZoneChildren( zone.Child() );
|
||||
if( children.is_magic() )
|
||||
{
|
||||
auto& vec = *(Vector<ZoneEvent>*)&children;
|
||||
for( auto& v : vec )
|
||||
{
|
||||
const auto childSpan = std::max( int64_t( 0 ), v.End() - v.Start() );
|
||||
time += childSpan;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( auto& v : children )
|
||||
{
|
||||
const auto childSpan = std::max( int64_t( 0 ), v->End() - v->Start() );
|
||||
time += childSpan;
|
||||
}
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
@ -13672,12 +13753,25 @@ int64_t View::GetZoneChildTimeFast( const ZoneEvent& zone )
|
||||
int64_t time = 0;
|
||||
if( zone.Child() >= 0 )
|
||||
{
|
||||
for( auto& v : m_worker.GetZoneChildren( zone.Child() ) )
|
||||
auto& children = m_worker.GetZoneChildren( zone.Child() );
|
||||
if( children.is_magic() )
|
||||
{
|
||||
auto& vec = *(Vector<ZoneEvent>*)&children;
|
||||
for( auto& v : vec )
|
||||
{
|
||||
assert( v.End() >= 0 );
|
||||
time += v.End() - v.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( auto& v : children )
|
||||
{
|
||||
assert( v->End() >= 0 );
|
||||
time += v->End() - v->Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user