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 21:47:21 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-08-14 21:47:21 +0300
commitee77ff020ad876bdb4b5b0fd5be058225f113683 (patch)
treefeb5c7b3faaefcc8ee29dcba0ea8d7add141d466 /server/TracyView.cpp
parenta194c937400418f37eae1ee5224acd6d93731f12 (diff)
Optimize calculation of zone running time.
Diffstat (limited to 'server/TracyView.cpp')
-rw-r--r--server/TracyView.cpp56
1 files changed, 35 insertions, 21 deletions
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index db5212f9..e6bd47be 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -4690,25 +4690,32 @@ void View::DrawZoneInfoWindow()
const auto end = m_worker.GetZoneEnd( ev );
auto eit = std::upper_bound( it, ctx->v.end(), end, [] ( const auto& l, const auto& r ) { return l < r.start; } );
uint64_t cnt = std::distance( it, eit );
- auto bit = it;
- 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;
- }
- TextFocused( "Running state time:", TimeToString( running ) );
- if( ztime != 0 )
+ if( cnt == 1 )
{
+ TextFocused( "Running state time:", TimeToString( ztime ) );
ImGui::SameLine();
- ImGui::TextDisabled( "(%.2f%%)", 100.f * running / ztime );
+ TextDisabledUnformatted( "(100%)" );
+ TextFocused( "Running state regions:", "1" );
}
- TextFocused( "Running state regions:", RealToString( cnt, true ) );
-
- if( cnt > 1 )
+ else
{
+ auto bit = it;
+ int64_t running = it->end - ev.start;
+ ++it;
+ for( int64_t i=0; i<cnt-2; i++ )
+ {
+ running += it->end - it->start;
+ ++it;
+ }
+ running += end - it->start;
+ TextFocused( "Running state time:", TimeToString( running ) );
+ if( ztime != 0 )
+ {
+ ImGui::SameLine();
+ ImGui::TextDisabled( "(%.2f%%)", 100.f * running / ztime );
+ }
+ TextFocused( "Running state regions:", RealToString( cnt, true ) );
+
--eit;
if( ImGui::TreeNode( "Wait regions" ) )
{
@@ -11610,15 +11617,22 @@ bool View::GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, in
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 )
+ if( cnt == 1 )
+ {
+ time = end - ev.start;
+ }
+ else
{
- const auto t0 = std::max( ev.start, it->start );
- const auto t1 = (int64_t)std::min<uint64_t>( end, it->end );
- running += t1 - t0;
+ int64_t running = it->end - ev.start;
++it;
+ for( int64_t i=0; i<cnt-2; i++ )
+ {
+ running += it->end - it->start;
+ ++it;
+ }
+ running += end - it->start;
+ time = running;
}
- time = running;
return true;
}