From 50efa8f67211d5e7b2cdc22d4b72d50c9c4a2bd9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 10 Nov 2019 01:08:15 +0100 Subject: [PATCH] Adapt time distribution calculation to magic vectors. --- server/TracyView.cpp | 42 ++++++++++++++++++++++++++++++++++-------- server/TracyView.hpp | 8 ++++++-- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 6c156fd7..9b5e91c0 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -5407,16 +5407,29 @@ void View::CalcZoneTimeData( flat_hash_map= 0 ); const auto& children = m_worker.GetZoneChildren( zone.Child() ); + if( children.is_magic() ) + { + CalcZoneTimeDataImpl>( *(Vector*)( &children ), data, zit, zone ); + } + else + { + CalcZoneTimeDataImpl>( children, data, zit, zone ); + } +} +template +void View::CalcZoneTimeDataImpl( const V& children, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ) +{ + Adapter a; for( auto& child : children ) { - const auto t = m_worker.GetZoneEnd( *child ) - child->Start(); + const auto t = m_worker.GetZoneEnd( a(child) ) - a(child).Start(); zit->second.time -= t; } for( auto& child : children ) { - const auto srcloc = child->SrcLoc(); - const auto t = m_worker.GetZoneEnd( *child ) - child->Start(); + const auto srcloc = a(child).SrcLoc(); + const auto t = m_worker.GetZoneEnd( a(child) ) - a(child).Start(); auto it = data.find( srcloc ); if( it == data.end() ) { @@ -5427,7 +5440,7 @@ void View::CalcZoneTimeData( flat_hash_mapsecond.time += t; it->second.count++; } - if( child->Child() >= 0 ) CalcZoneTimeData( data, it, *child ); + if( a(child).Child() >= 0 ) CalcZoneTimeData( data, it, a(child) ); } } @@ -5435,21 +5448,34 @@ void View::CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map= 0 ); const auto& children = m_worker.GetZoneChildren( zone.Child() ); + if( children.is_magic() ) + { + CalcZoneTimeDataImpl>( *(Vector*)( &children ), ctx, data, zit, zone ); + } + else + { + CalcZoneTimeDataImpl>( children, ctx, data, zit, zone ); + } +} +template +void View::CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ) +{ + Adapter a; for( auto& child : children ) { int64_t t; uint64_t cnt; - const auto res = GetZoneRunningTime( ctx, *child, t, cnt ); + const auto res = GetZoneRunningTime( ctx, a(child), t, cnt ); assert( res ); zit->second.time -= t; } for( auto& child : children ) { - const auto srcloc = child->SrcLoc(); + const auto srcloc = a(child).SrcLoc(); int64_t t; uint64_t cnt; - const auto res = GetZoneRunningTime( ctx, *child, t, cnt ); + const auto res = GetZoneRunningTime( ctx, a(child), t, cnt ); assert( res ); auto it = data.find( srcloc ); if( it == data.end() ) @@ -5461,7 +5487,7 @@ void View::CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_mapsecond.time += t; it->second.count++; } - if( child->Child() >= 0 ) CalcZoneTimeData( ctx, data, it, *child ); + if( a(child).Child() >= 0 ) CalcZoneTimeData( ctx, data, it, a(child) ); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 4b85abde..1d2ee169 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -223,8 +223,12 @@ private: int64_t GetZoneSelfTime( const GpuEvent& zone ); bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt ); - void CalcZoneTimeData( flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); - void CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); + tracy_force_inline void CalcZoneTimeData( flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); + tracy_force_inline void CalcZoneTimeData( const ContextSwitch* ctx, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); + template + void CalcZoneTimeDataImpl( const V& children, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); + template + void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, flat_hash_map>& data, flat_hash_map>::iterator zit, const ZoneEvent& zone ); void SetPlaybackFrame( uint32_t idx );