From 73df330dd51c6c7a50c21b33f6e36bfdcc89cc07 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 23 Sep 2017 23:59:56 +0200 Subject: [PATCH] Recursive, incomplete zone insertion into timeline. --- server/TracyView.cpp | 49 +++++++++++++++++++++++++++++--------------- server/TracyView.hpp | 2 ++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 065e0f1b..00ffca9e 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -224,7 +224,6 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ) { auto it = m_pendingEndZone.find( id ); auto zone = m_slab.Alloc(); - 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& 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 ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 4bedbddf..0a589e08 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -57,6 +57,8 @@ private: void NewZone( Event* zone, uint64_t thread ); void UpdateZone( Event* zone ); + void InsertZone( Event* zone, Event* parent, Vector& vec ); + uint64_t GetFrameTime( size_t idx ) const; uint64_t GetFrameBegin( size_t idx ) const; uint64_t GetFrameEnd( size_t idx ) const;