Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-08-14 18:54:50 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-08-14 19:28:52 +0300
commit858c94e12e79670eb37606e5732f88c12ace7d5a (patch)
tree37d1e070567e6ac62ad851faf39d7641e4e508c5 /server/TracyView.cpp
parent0b12db5ee6bbce3609f8384e6f154a679b713e11 (diff)
Add interface for calculation zone running time.
Diffstat (limited to 'server/TracyView.cpp')
-rw-r--r--server/TracyView.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index 77cedf78..2f6a5687 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -11483,4 +11483,23 @@ int64_t View::GetZoneSelfTime( const GpuEvent& zone )
return selftime;
}
+bool View::GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt )
+{
+ auto it = std::lower_bound( ctx->v.begin(), ctx->v.end(), ev.start, [] ( const auto& l, const auto& r ) { return (uint64_t)l.end < (uint64_t)r; } );
+ if( it == ctx->v.end() ) return false;
+ const auto end = m_worker.GetZoneEnd( ev );
+ const auto eit = std::upper_bound( it, ctx->v.end(), end, [] ( const auto& l, const auto& r ) { return l < r.start; } );
+ cnt = std::distance( it, eit );
+ int64_t running = 0;
+ while( it < eit )
+ {
+ const auto t0 = std::max( ev.start, it->start );
+ const auto t1 = (int64_t)std::min<uint64_t>( end, it->end );
+ running += t1 - t0;
+ ++it;
+ }
+ time = running;
+ return true;
+}
+
}