From 4c7f6989465cd91bef0c0410f2a58e1a130d10e0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 8 Feb 2020 13:18:42 +0100 Subject: [PATCH] Display compression ratio in update utility. --- update/build/win32/update.vcxproj | 2 ++ update/build/win32/update.vcxproj.filters | 6 ++++++ update/src/update.cpp | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/update/build/win32/update.vcxproj b/update/build/win32/update.vcxproj index 5e064373..bba6f03d 100644 --- a/update/build/win32/update.vcxproj +++ b/update/build/win32/update.vcxproj @@ -134,6 +134,7 @@ + @@ -157,6 +158,7 @@ + diff --git a/update/build/win32/update.vcxproj.filters b/update/build/win32/update.vcxproj.filters index 81e6be7b..801fe253 100644 --- a/update/build/win32/update.vcxproj.filters +++ b/update/build/win32/update.vcxproj.filters @@ -39,6 +39,9 @@ server + + server + @@ -107,5 +110,8 @@ server + + server + \ No newline at end of file diff --git a/update/src/update.cpp b/update/src/update.cpp index 87ffe6bd..c30d95da 100644 --- a/update/src/update.cpp +++ b/update/src/update.cpp @@ -9,6 +9,7 @@ #include "../../server/TracyFileRead.hpp" #include "../../server/TracyFileWrite.hpp" +#include "../../server/TracyPrint.hpp" #include "../../server/TracyVersion.hpp" #include "../../server/TracyWorker.hpp" @@ -70,6 +71,7 @@ int main( int argc, char** argv ) try { + float ratio; int inVer; { tracy::Worker worker( *f, tracy::EventType::All, false ); @@ -87,6 +89,9 @@ int main( int argc, char** argv ) printf( "Saving... \r" ); fflush( stdout ); worker.Write( *w ); + w->Finish(); + const auto stats = w->GetCompressionStatistics(); + ratio = 100.f * stats.second / stats.first; inVer = worker.GetTraceVersion(); } @@ -100,7 +105,10 @@ int main( int argc, char** argv ) const auto outSize = ftello64( out ); fclose( out ); - printf( "%s (%i.%i.%i) {%zu KB} -> %s (%i.%i.%i) {%zu KB} %.2f%% size change\n", input, inVer >> 16, ( inVer >> 8 ) & 0xFF, inVer & 0xFF, size_t( inSize / 1024 ), output, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, size_t( outSize / 1024 ), float( outSize ) / inSize * 100 ); + printf( "%s (%i.%i.%i) {%s} -> %s (%i.%i.%i) {%s, %.2f%%} %.2f%% size change\n", + input, inVer >> 16, ( inVer >> 8 ) & 0xFF, inVer & 0xFF, tracy::MemSizeToString( inSize ), + output, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, tracy::MemSizeToString( outSize ), ratio, + float( outSize ) / inSize * 100 ); } catch( const tracy::UnsupportedVersion& e ) {