Compressor Size Ratio Compression Decompression
gzip -9 555M 59% 2m39.840s 0m16.495s
bzip2 -9 531M 56% 4m10.541s 1m27.720s
xz -9 457M 48% 13m55.730s 0m53.290sBandwidth is cheap. Stick to gzip.
Bandwidth is cheap. Stick to gzip.
It's not as simple as that. Which one is better depends on the use case. If you're sending a one-off file to somebody, sure, gzip is better. But if you want to distribute a file to a large number of people (like Linux distributions do with their packages), the extra CPU time is insignificant compared to the bandwidth saved over the course of thousands of downloads.
This affects energy consumption, too.
And think about both mobile and servers. Those systems are usually more sensible to high CPU load.
I have a draft blog post with analysis of different protocols with valgrind and other tools. But it is so much data to present and graph I never get around to finish it :(
> If you look at some of the stats people are posting, it's the
> compression that takes the most time, not the decompression
5 vs. 11 seconds. Worse than 2x slower decompression:http://news.ycombinator.com/item?id=1458697
If you have to wait minutes to download the files it doesn't matter, but if you already have the file locally it is very annoying.
Also if this is used extensively on projects with a large server deployment this matters even more related to latency and energy consumption. That's why Google has their own compression algorithms derived from BMDiff and LZW (Zippy.) Think about it. Speed matters.
Here are some comparisons between the big 3 compression algorithms (taken from http://blogs.reucon.com/srt/tags/compression/ -- he used a 163 MB Mysql dump file for the tests):