From b7930f67daf891c88bd572802ce3eb48d49af28d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Jun 2018 00:39:22 +0200 Subject: [PATCH] Calculate total self time of zones. --- server/TracyWorker.cpp | 16 ++++++++++++++-- server/TracyWorker.hpp | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 75644208..9a813bde 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1499,7 +1499,7 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) m_data.lastTime = std::max( m_data.lastTime, zone->end ); #ifndef TRACY_NO_STATISTICS - const auto timeSpan = zone->end - zone->start; + auto timeSpan = zone->end - zone->start; if( timeSpan > 0 ) { auto it = m_data.sourceLocationZones.find( zone->srcloc ); @@ -1507,6 +1507,12 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) it->second.min = std::min( it->second.min, timeSpan ); it->second.max = std::max( it->second.max, timeSpan ); it->second.total += timeSpan; + for( auto& v : zone->child ) + { + const auto childSpan = std::max( 0ll, v->end - v->start ); + timeSpan -= childSpan; + } + it->second.selfTotal += timeSpan; } #endif } @@ -2089,12 +2095,18 @@ void Worker::ReadTimeline( FileRead& f, Vector& vec, uint16_t thread if( zone->end >= 0 ) { - const auto timeSpan = zone->end - zone->start; + auto timeSpan = zone->end - zone->start; if( timeSpan > 0 ) { it->second.min = std::min( it->second.min, timeSpan ); it->second.max = std::max( it->second.max, timeSpan ); it->second.total += timeSpan; + for( auto& v : zone->child ) + { + const auto childSpan = std::max( 0ll, v->end - v->start ); + timeSpan -= childSpan; + } + it->second.selfTotal += timeSpan; } } #endif diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index f70517fa..c53bc7ed 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -60,12 +60,14 @@ class Worker : min( std::numeric_limits::max() ) , max( std::numeric_limits::min() ) , total( 0 ) + , selfTotal( 0 ) {} Vector zones; int64_t min; int64_t max; int64_t total; + int64_t selfTotal; }; struct DataBlock