From d49b0059004480513df2704f029d0d70db2278c7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 30 Dec 2018 23:14:00 +0100 Subject: [PATCH] Display dump file size change in the update utility. --- NEWS | 1 + update/src/update.cpp | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index d0e660ac..535a4419 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ v0.5 (xxxx-xx-xx) ----------------- - Major decrease of trace dump file size. +- Display dump file size change in the update utility. v0.4.1 (2018-12-30) ------------------- diff --git a/update/src/update.cpp b/update/src/update.cpp index 113c0e8a..603ad7b3 100644 --- a/update/src/update.cpp +++ b/update/src/update.cpp @@ -50,18 +50,31 @@ int main( int argc, char** argv ) try { - tracy::Worker worker( *f ); - - auto w = std::unique_ptr( tracy::FileWrite::Open( output, hc ? tracy::FileWrite::Compression::Slow : tracy::FileWrite::Compression::Fast ) ); - if( !w ) + int inVer; { - fprintf( stderr, "Cannot open output file!\n" ); - exit( 1 ); - } - worker.Write( *w ); + tracy::Worker worker( *f ); - const auto inVer = worker.GetTraceVersion(); - printf( "%s (%i.%i.%i) -> %s (%i.%i.%i)\n", input, inVer >> 16, ( inVer >> 8 ) & 0xFF, inVer & 0xFF, output, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ); + auto w = std::unique_ptr( tracy::FileWrite::Open( output, hc ? tracy::FileWrite::Compression::Slow : tracy::FileWrite::Compression::Fast ) ); + if( !w ) + { + fprintf( stderr, "Cannot open output file!\n" ); + exit( 1 ); + } + worker.Write( *w ); + inVer = worker.GetTraceVersion(); + } + + FILE* in = fopen( input, "rb" ); + fseek( in, 0, SEEK_END ); + const auto inSize = ftell( in ); + fclose( in ); + + FILE* out = fopen( output, "rb" ); + fseek( out, 0, SEEK_END ); + const auto outSize = ftell( 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, inSize / 1024, output, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, outSize / 1024, float( outSize ) / inSize * 100 ); } catch( const tracy::UnsupportedVersion& e ) {