From 79dec4eafef13ad9149939c5440b090846fb9bd4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 23 Nov 2017 01:23:40 +0100 Subject: [PATCH] Display compression ratio and uncompressed data throughput. --- server/TracyView.cpp | 8 +++++++- server/TracyView.hpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 9203c81b..9dcac3fb 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -125,6 +125,7 @@ View::View( const char* addr ) , m_sourceLocationExpand( { 0 } ) , m_zonesCnt( 0 ) , m_mbps( 64 ) + , m_compRatio( 1 ) , m_stream( LZ4_createStreamDecode() ) , m_buffer( new char[TargetFrameSize*3 + 1] ) , m_bufferOffset( 0 ) @@ -412,6 +413,7 @@ void View::Worker() std::chrono::time_point t0; uint64_t bytes = 0; + uint64_t decBytes = 0; { WelcomeMessage welcome; @@ -451,6 +453,7 @@ void View::Worker() auto sz = LZ4_decompress_safe_continue( m_stream, lz4buf, buf, lz4sz, TargetFrameSize ); assert( sz >= 0 ); + decBytes += sz; char* ptr = buf; const char* end = buf + sz; @@ -477,8 +480,10 @@ void View::Worker() std::lock_guard lock( m_mbpslock ); m_mbps.erase( m_mbps.begin() ); m_mbps.emplace_back( bytes / ( td * 125.f ) ); + m_compRatio = float( bytes ) / decBytes; t0 = t1; bytes = 0; + decBytes = 0; } if( m_terminate ) @@ -1540,9 +1545,9 @@ void View::DrawConnection() const auto ty = ImGui::GetFontSize(); const auto cs = ty * 0.9f; - ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders ); { std::lock_guard lock( m_mbpslock ); + ImGui::Begin( m_addr.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders ); const auto mbps = m_mbps.back(); char buf[64]; if( mbps < 0.1f ) @@ -1556,6 +1561,7 @@ void View::DrawConnection() ImGui::Dummy( ImVec2( cs, 0 ) ); ImGui::SameLine(); ImGui::PlotLines( buf, m_mbps.data(), m_mbps.size(), 0, nullptr, 0, std::numeric_limits::max(), ImVec2( 150, 0 ) ); + ImGui::Text( "Ratio %.1f%% Real: %6.2f Mbps", m_compRatio * 100.f, mbps / m_compRatio ); } ImGui::Text( "Memory usage: %.2f MB", memUsage.load( std::memory_order_relaxed ) / ( 1024.f * 1024.f ) ); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 31ce4b3c..a7dfa6f1 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -191,6 +191,7 @@ private: NonRecursiveBenaphore m_mbpslock; std::vector m_mbps; + float m_compRatio; // not used for vis - no need to lock flat_hash_set> m_pendingStrings;