From 3fcd73680c166e9351e49d6b8face959322d8e47 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 18 Jun 2019 20:56:42 +0200 Subject: [PATCH] Simulate client activity time advancement. --- profiler/src/main.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 7ccf82bf..bcef53db 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -282,6 +282,7 @@ int main( int argc, char** argv ) glfwSetWindowTitle( window, title ); } + const auto time = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count(); if( !broadcastListen ) { broadcastListen = new tracy::UdpListen(); @@ -296,7 +297,6 @@ int main( int argc, char** argv ) tracy::IpAddress addr; int len; auto msg = broadcastListen->Read( len, addr ); - const auto t = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count(); if( msg ) { assert( len <= sizeof( tracy::BroadcastMessage ) ); @@ -313,11 +313,11 @@ int main( int argc, char** argv ) auto it = clients.find( addr.GetNumber() ); if( it == clients.end() ) { - clients.emplace( addr.GetNumber(), ClientData { t, protoVer, activeTime, procname, address } ); + clients.emplace( addr.GetNumber(), ClientData { time, protoVer, activeTime, procname, address } ); } else { - it->second.time = t; + it->second.time = time; it->second.activeTime = activeTime; if( it->second.protocolVersion != protoVer ) it->second.protocolVersion = protoVer; if( strcmp( it->second.procName.c_str(), procname ) != 0 ) it->second.procName = procname; @@ -328,7 +328,7 @@ int main( int argc, char** argv ) auto it = clients.begin(); while( it != clients.end() ) { - const auto diff = t - it->second.time; + const auto diff = time - it->second.time; if( diff > 4000 ) // 4s { it = clients.erase( it ); @@ -495,13 +495,14 @@ int main( int argc, char** argv ) view = std::make_unique( v.second.address.c_str(), fixedWidth, SetWindowTitleCallback ); } ImGui::NextColumn(); + const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll; if( badProto ) { - tracy::TextDisabledUnformatted( tracy::TimeToString( v.second.activeTime * 1000000000ll ) ); + tracy::TextDisabledUnformatted( tracy::TimeToString( acttime ) ); } else { - ImGui::TextUnformatted( tracy::TimeToString( v.second.activeTime * 1000000000ll ) ); + ImGui::TextUnformatted( tracy::TimeToString( acttime ) ); } ImGui::NextColumn(); if( badProto )