Comparison of conpresison settings

Aug 24, 2011 at 5:33 PM

Has anyone done a comparison of CompressionMethod and CompressionLevel values to see how they affect the time to compress, time to decompress, and degree of compression?

Also, other than noted in the documentation for CompressionLelvel, do these values affect compatibility with common archiving tools?


Aug 24, 2011 at 6:36 PM

I did some tests a long while but never posted the results publicly.  I observed a tradeoff between speed and size, but it varies depending on the type of input.   In short, there's no fixed answer, You'll have to see how it works for you, with your data.

The compressionlevel applies only to DEFLATE, and does not affect unzipp-ability by other tools.  There are some options in the DEFLATE algorithm, and higher compressionlevels use different options.  Any compressionLevel will produce a valid DEFLATE stream, which will uncompress in other tools. CompressionMethod, on the other hand, is a different story.  Virtually all tools support DEFLATE, not all support Bzip2.   YMMV.   ps: CompressionLevel does not affect Bzip2 compression.


Aug 24, 2011 at 6:50 PM

THanks again Cheeso,

How does the performance of the BZip2 algoritum compare to the deflate algorithum?


Aug 24, 2011 at 6:57 PM

BZip2 is noticeably slower, but supposedly it is 20% more effective in compression.  but as always, YMMV.

Aug 25, 2011 at 9:55 PM
Edited Aug 25, 2011 at 10:05 PM

For posterity, here are my results from compressing a 62,087,168 byte .mde file:

Level         Size               Time
deflate/1   18,505,484   17.54211
deflate/3   17,769,849   12.48181
deflate/4   17,303,198   10.90534
deflate/5   16,990,365   11.87408
deflate/9   16,661,852   38.719989
bzip2        12,576,075   97.13316

Time is in seconds and represents the total time to run the compression code in my program. Everything else is identical. Size is in bytes.

So the bzip2 created a 27% smaller file and took 791% of the time as compared to the fastest level of deflate, which was level 4.


Aug 26, 2011 at 4:30 AM

Very Interesting - thanks for contributing that.