tags:

views:

304

answers:

4

What is the best memory and file compressor lzo, bzip2, zlib or lzma ?

+6  A: 

It depends on the sort of data that you're going to be throwing at the compressor. For our particular case (VMWare images, executables and source files), we opted for 7zip (LZMA, I believe) in Ultra mode, simply because it gave us better compression than any others. We weren't that fussed about the speed of compression since that is easily amortized. Speed of decompression was important but not nearly as important as file size.

Your mileage may vary. My advice would be to try them all with the sort of data sets you're likely to compress and see which one is better (whatever your definition of 'better' entails). Or provide a translation layer so you can easily replace one with another.

paxdiablo
but I already know that someone can write something better
Arabcoder
@Arabcoder, I'm not saying you should write your own compressor. Just that, *if* you want to be able to switch between compressors (when you discover there's a better one), it may be good to abstract away the compression interface with a layer of your own. My preferred solution is to find the one that works best, and use it. That final sentence was just an option if you thought you needed switchability between the different compressors.
paxdiablo
+1 for the abstraction layer.
Jurily
+2  A: 

Here's a nice article for you:

Mostly, this benchmark turns out as expected (and advertised by the lzma authors). Gzip is fastest on compression; bzip2 comes second for compression times and lzma finishes last. Decompression is different: gzip is fastest again, but lzma is faster than bzip2, sometimes nearly by a factor of three. Compression ratio is where gzip shows its age: its compression ratio is worst (except when packing already compressed stuff). Bzip2 bests lzma's compression ration in three cases of five (two of four if you don't count the PNG). On average, however, lzma compresses better by a hair.

Jurily
A: 

Apart from the resource usage/speed etc i think type of files used for compression also matter. Try compressing an mp3/wma file ,even at higher bitrates , it wont get compressed significanly. However take some source files and compress it, you will see it reduces the size many folds.

Kavitesh Singh
A: 

Look at the best compression benchmark site: link text

bill
thanks bill, did I know you ?
Arabcoder