From ae7b825c74ab7cb16fba82810f334f9023b87074 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 12 Nov 2020 13:26:14 +0100 Subject: [PATCH] add gzip compression size info --- pio/gzip-firmware.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pio/gzip-firmware.py b/pio/gzip-firmware.py index 248bb5a02..e29c05576 100644 --- a/pio/gzip-firmware.py +++ b/pio/gzip-firmware.py @@ -19,5 +19,10 @@ def bin_gzip(source, target, env): with open(bin_file,"rb") as fp: with gzip.open(gzip_file, "wb", compresslevel = 9) as f: shutil.copyfileobj(fp, f) + + ORG_FIRMWARE_SIZE = os.stat(bin_file).st_size + GZ_FIRMWARE_SIZE = os.stat(gzip_file).st_size + + print("Compression reduced firmware size by {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE)) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])