Skip to content

Commit

Permalink
Added debug output of zlib compression factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Eichhoernchen authored and Eichhoernchen committed Feb 13, 2012
1 parent 9e6e9fa commit 05c83c6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions siriServer.py
Expand Up @@ -400,6 +400,11 @@ def flush_unzipped_output(self):
self.output_buffer += self.compressor.compress(self.unzipped_output_buffer)
#make sure everything is compressed
self.output_buffer += self.compressor.flush(zlib.Z_SYNC_FLUSH)
ratio = float(len(self.unzipped_output_buffer))/float(len(self.output_buffer)) - 1
if ratio < 0:
self.logger.debug("Blowed up by {0:.2f} bytes ({1:.2%}) due to compression".format(-1*ratio*len(self.unzipped_output_buffer),ratio))
else:
self.logger.debug("Saved {0:.2f} bytes ({1:.2%}) using compression".format(ratio*len(self.unzipped_output_buffer), ratio))
self.unzipped_output_buffer = ""

self.flush_output_buffer()
Expand Down

0 comments on commit 05c83c6

Please sign in to comment.