Recursive, incomplete zone insertion into timeline.

This commit is contained in:
Bartosz Taudul 2017-09-23 23:59:56 +02:00
parent b89adbaf8c
commit 73df330dd5
2 changed files with 34 additions and 17 deletions

View File

@ -224,7 +224,6 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev )
{
auto it = m_pendingEndZone.find( id );
auto zone = m_slab.Alloc<Event>();
zone->parent = nullptr;
CheckString( ev.filename );
CheckString( ev.function );
@ -360,22 +359,7 @@ void View::NewZone( Event* zone, uint64_t thread )
timeline = &m_threads[it->second].timeline;
}
if( !timeline->empty() )
{
const auto lastend = timeline->back()->end;
if( lastend != -1 && lastend < zone->start )
{
timeline->push_back( zone );
}
else
{
}
}
else
{
timeline->push_back( zone );
}
InsertZone( zone, nullptr, *timeline );
}
void View::UpdateZone( Event* zone )
@ -383,6 +367,37 @@ void View::UpdateZone( Event* zone )
assert( zone->end != -1 );
}
void View::InsertZone( Event* zone, Event* parent, Vector<Event*>& vec )
{
if( !vec.empty() )
{
const auto lastend = vec.back()->end;
if( lastend != -1 && lastend < zone->start )
{
zone->parent = parent;
vec.push_back( zone );
}
else
{
auto it = std::upper_bound( vec.begin(), vec.end(), zone->start, [] ( const auto& l, const auto& r ) { return l < r->start; } );
if( it == vec.end() )
{
assert( vec.back()->end == -1 );
InsertZone( zone, vec.back(), vec.back()->child );
}
else
{
}
}
}
else
{
zone->parent = parent;
vec.push_back( zone );
}
}
uint64_t View::GetFrameTime( size_t idx ) const
{
if( idx < m_frames.size() - 1 )

View File

@ -57,6 +57,8 @@ private:
void NewZone( Event* zone, uint64_t thread );
void UpdateZone( Event* zone );
void InsertZone( Event* zone, Event* parent, Vector<Event*>& vec );
uint64_t GetFrameTime( size_t idx ) const;
uint64_t GetFrameBegin( size_t idx ) const;
uint64_t GetFrameEnd( size_t idx ) const;