gzip, bzip2, xz 工具比較
原文:https://www.rootusers.com/gzip-vs-bzip2-vs-xz-performance-comparison
Conclusion
If you are interactively compressing files on the fly then you may want to do this quickly with gzip -6 (default compression level) or xz -1, however if you’re configuring log rotation which will run automatically over night during a low resource usage period then it may be acceptable to use more CPU resources with xz -9 to save the greatest amount of space possible. For instance kernel.org compress the Linux kernel with xz, in this case spending extra time to compress the file well once makes sense when it will be downloaded and decompressed thousands of times resulting in bandwidth savings yet still decent decompression speeds.
Based on the results here, if you’re simply after being able to compress and decompress files as fast as possible with little regard to the compression ratio, then gzip is the tool for you. If you want a better compression ratio to save more disk space and are willing to spend extra processing time to get it then xz will be best to use. Although xz takes the longest to compress at higher compression levels, it has a fairly good decompression speed and compresses quite fast at lower levels. Bzip2 provides a good trade off between compression ratio and processing speed however it takes the longest to decompress so it may be a good option if the content that is being compressed will be infrequently decompressed.
In the end the best option will come down to what you’re after between processing time and compression ratio. With disk space continually becoming cheaper and available in larger sizes you may be fine with saving some CPU resources and processing time to store slightly larger files. Regardless of the tool that you use, compression is a great resource for saving storage space.
Quick Benchmark: Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO
Tarball mode from linux-3.3, original size: 466083840 (445M)
- Compression ratio
gzip | lz4 | lzop | |
---|---|---|---|
1 | 26.80% | 35.60% | 36.00% |
2 | 25.50% | 35.60% | 35.80% |
3 | 24.70% | 35.60% | 35.80% |
5 | 22.00% | - | 35.80% |
7 | 21.50% | - | 24.90% |
9 | 21.40% | - | 24.60% |
- Compression time
gzip | lz4 | lzop | |
---|---|---|---|
1 | 8.1s | 1.3s | 1.6s |
2 | 8.5s | 1.4s | 1.6s |
3 | 9.6s | 1.3s | 1.5s |
5 | 14s | - | 1.5s |
7 | 21s | - | 35s |
9 | 33s | - | 1m5s |
- Decompression time
gzip | lz4 | lzop | |
---|---|---|---|
1 | 3.5s | 0.4s | 1.5s |
2 | 3s | 0.3s | 1.4s |
3 | 3.2s | 0.4s | 1.4s |
5 | 3.2s | - | 1.5s |
7 | 3s | - | 1.3s |
9 | 3s | - | 1.2s |
Compression Benchmarks: brotli, gzip, xz, bz2
原文: https://www.opencpu.org/posts/brotli-benchmarks/?spm=ata.13261165.0.0.45e51b1c0N9oFD
Brotli is a new compression algorithm optimized for the web, in particular small text documents. Brotli decompression is at least as fast as for gzip while significantly improving the compression ratio. The price we pay is that compression is much slower than gzip