From 78067eb35ed9f992033bdf40ca8c099fdf576bf9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 5 Oct 2017 14:02:08 +0200 Subject: [PATCH] Calculate lock wait counts. --- server/TracyEvent.hpp | 1 + server/TracyView.cpp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index b09321d7..5f43e658 100755 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -42,6 +42,7 @@ struct LockEvent int64_t time; uint64_t thread; uint8_t lockCount; + uint8_t waitCount; Type type; }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 40d2d299..6312b447 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -719,25 +719,33 @@ void View::InsertLockEvent( LockMap& lockmap, LockEvent* lev ) void View::UpdateLockCount( Vector& timeline, size_t pos ) { - uint8_t count = pos == 0 ? 0 : timeline[pos-1]->lockCount; + uint8_t lockCount = pos == 0 ? 0 : timeline[pos-1]->lockCount; + uint8_t waitCount = pos == 0 ? 0 : timeline[pos-1]->waitCount; const auto end = timeline.size(); while( pos != end ) { switch( timeline[pos]->type ) { + case LockEvent::Type::Wait: + assert( waitCount < std::numeric_limits::max() ); + waitCount++; + break; case LockEvent::Type::Obtain: - assert( count < std::numeric_limits::max() ); - count++; + assert( lockCount < std::numeric_limits::max() ); + assert( waitCount > 0 ); + lockCount++; + waitCount--; break; case LockEvent::Type::Release: - assert( count > 0 ); - count--; + assert( lockCount > 0 ); + lockCount--; break; default: break; } - timeline[pos]->lockCount = count; + timeline[pos]->lockCount = lockCount; + timeline[pos]->waitCount = waitCount; pos++; } }