压缩算法比较: Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO
源网址: https://catchchallenger.first-world.info/wiki/Quick_Benchmark:_Gzip_vs_Bzip2_vs_LZMA_vs_XZ_vs_LZ4_vs_LZO
Selected archives
I have selected:
- Source of the kernel to test source compression
- Stream protocol with flush
Test conditions
Tests were run on a desktop:
- Intel Core i5 CPU 750 at 2.67GHz
- 8GB of DDR3 memory
- tmpfs as ram disk is used
- Linux kernel 3.3.2, gentoo amd64
- CFLAGS: -pipe -O2 -g -floop-block -floop-interchange -fgraphite
- bzip2-1.0.6-r3, xz-utils-5.0.3, gzip-1.4
Only normal mode will be tested firstly.
The file test results
Note: The first column with numbers 1..9 indicates the compression setting passed to gzip, bzip2 and lzmash (e.g. "gzip -9").
Tarball mode from linux-3.3, original size: 466083840 (445M)
Compressed file size in bytes
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 124875819 (120M) | 93997047 (90M) | 85618192 (82M) | 72042179 (69M) | 85630688 (82M) | 72069084 (69M) | 165844264 (159M) | 168012430 (161M) |
2 | 119040249 (114M) | 87741348 (84M) | 81480824 (78M) | 70264395 (68M) | 81492504 (78M) | 70282944 (68M) | 165844264 (159M) | 166987891 (160M) |
3 | 114931686 (110M) | 84816957 (81MB) | 79575087 (76MB) | 69015118 (66MB) | 79586568 (76MB) | 69029204 (66MB) | 165844264 (159M) | 166987891 (160M) |
5 | 102328357 (98M) | 81837328 (79M) | 69557610 (67M) | 67879362 (65M) | 69583428 (67M) | 67875988 (65M) | - | 166987891 (160M) |
7 | 100128597 (96M) | 80197758 (77M) | 67276420 (65M) | 66868212 (64M) | 67294092 (65M) | 66852780 (64M) | - | 116205578 (111M) |
9 | 99740486 (96M) | 78963640 (76M) | 65841213 (63M) | 65362226 (63M) | 65859432 (63M) | 65372696 (63M) | - | 114824102 (110M) |
Compression ratio
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 26.8% | 20.2% | 18.4% | 15.5% | 18.4% | 15.5% | 35.6% | 36.0% |
2 | 25.5% | 18.8% | 17.5% | 15.1% | 17.5% | 15.1% | 35.6% | 35.8% |
3 | 24.7% | 18.2% | 17.1% | 14.8% | 17.1% | 14.8% | 35.6% | 35.8% |
5 | 22.0% | 17.6% | 14.9% | 14.6% | 14.9% | 14.6% | - | 35.8% |
7 | 21.5% | 17.2% | 14.4% | 14.3% | 14.4% | 14.3% | - | 24.9% |
9 | 21.4% | 16.9% | 14.1% | 14.0% | 14.1% | 14.0% | - | 24.6% |
Compression time
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 8.1s | 58.3s | 31.7s | 4m37s | 32.2s | 4m40s | 1.3s | 1.6s |
2 | 8.5s | 58.4s | 40.7s | 4m49s | 41.9s | 4m53s | 1.4s | 1.6s |
3 | 9.6s | 59.1s | 1m2s | 4m36s | 1m1s | 4m39s | 1.3s | 1.5s |
5 | 14s | 1m1s | 3m5s | 5m | 3m6s | 4m53s | - | 1.5s |
7 | 21s | 1m2s | 4m14s | 5m52s | 4m13s | 5m57s | - | 35s |
9 | 33s | 1m3s | 4m48s | 6m40s | 4m51s | 6m40s | - | 1m5s |
- gzip -1 vs lz4 -1 on x86: lz4 6.2x more fast
- gzip -1 vs lz4 -1 on ARM: lz4 3.6x more fast
Decompression time
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 3.5s | 3.4s | 6.7s | 5.9s | 7.2s | 6.5s | 0.4s | 1.5s |
2 | 3s | 15.7 | 6.3s | 5.6s | 6.8s | 6.3s | 0.3s | 1.4s |
3 | 3.2s | 15.9s | 6s | 5.6s | 6.7s | 6.2s | 0.4s | 1.4s |
5 | 3.2s | 16s | 5.5s | 5.4s | 6.2s | 6s | - | 1.5s |
7 | 3s | 15s | 5.3s | 5.3s | 5.9s | 5.8s | - | 1.3s |
9 | 3s | 15s | 5s | 5.1s | 5.6s | 5.6s | - | 1.2s |
Memory requirements on compression
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 0.4MB | 1.1MB | 8.3MB | 12.6MB | 8.3MB | 12.5MB | 12MB | 0.7MB |
2 | 0.4MB | 1.9MB | 15.8MB | 24MB | 15.8MB | 24MB | 12MB | 0.7MB |
3 | 0.4MB | 2.7MB | 30.7MB | 46.9MB | 30.8MB | 47M | 13.2MB | 0.7MB |
5 | 0.4MB | 4.2MB | 93MB | 93MB | 93MB | 93MB | - | 0.7MB |
7 | 0.4MB | 5.7MB | 185MB | 185MB | 185MB | 185MB | - | 0.9MB |
9 | 0.4MB | 7.2MB | 672MB | 673MB | 673MB | 673MB | - | 0.9MB |
- Note: lz4 it's the program using this size, the code for internal lz4 use very less memory
Memory requirements on decompression
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
---|---|---|---|---|---|---|---|---|
gzip | bzip2 | lzma | lzma -e | xz | xz -e | lz4 | lzop | |
1 | 0.1MB | 0.3MB | 1MB | 1MB | 1MB | 1MB | 13MB | 0.2MB |
2 | 0.1MB | 0.9MB | 2.1MB | 2.1MB | 2.1MB | 2.1MB | 12MB | 0.2MB |
3 | 0.1MB | 1.1MB | 4.1MB | 4.1MB | 4.0MB | 4.0MB | 13MB | 0.2MB |
5 | 0.1MB | 1.9MB | 8.1MB | 8.1MB | 8.1MB | 8.1MB | - | 0.2MB |
7 | 0.1MB | 2.6MB | 16MB | 16MB | 16MB | 16MB | - | 0.2MB |
9 | 0.1MB | 3.4MB | 64MB | 64MB | 64MB | 64MB | - | 0.2MB |
- Note: lz4 it's the program using this size, the code for internal lz4 use very less memory
Cli used for -1 compression:
- time gzip -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;time gunzip linux-3.3.tar*
- time bzip2 -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;time bunzip2 linux-3.3.tar.bz2
- time lzma -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time unlzma linux-3.3.tar*
- time lzma -e -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time unlzma linux-3.3.tar*
- time xz -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time unxz linux-3.3.tar*
- time xz -e -1 linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time unxz linux-3.3.tar*
- time /home/user/lz4-read-only/lz4demo64 -c0 linux-3.3.tar linux-3.3.tar.lz4;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time /home/user/lz4-read-only/lz4demo64 -d linux-3.3.tar.lz4 linux-3.3.tar;rm linux-3.3.tar.*
- time lzop -1 linux-3.3.tar;rm linux-3.3.tar;du -ksh linux-3.3.tar*;ls -l linux-3.3.tar*;read PAUSe;time lzop -d linux-3.3.tar*;rm linux-3.3.tar.*
Stream test
Time to compress
gzip | zlib | lz4 | lz4hc | none | |
---|---|---|---|---|---|
gzip | zlib | lz4 | lz4hc | none | |
1 | 376 | 368 | 130 | 311 | 10 |
2 | 371 | 391 | |||
3 | 378 | 362 | |||
5 | 390 | 392 | |||
7 | 389 | 387 | |||
9 | 393 | 384 |
Time to decompress
gzip | zlib | lz4 | lz4hc | none | |
---|---|---|---|---|---|
gzip | zlib | lz4 | lz4hc | none | |
1 | 1797 | 1778 | 809 | 796 | 9 |
2 | 1841 | 1831 | |||
3 | 1771 | 1780 | |||
5 | 1806 | 1960 | |||
7 | 1861 | 1851 | |||
9 | 1835 | 1806 |
Messured with:
timespec tstart,tstop; clock_gettime(CLOCK_REALTIME, &tstart); //compression/decompression clock_gettime(CLOCK_REALTIME, &tstop); compressionTime+=((quint64)tstop.tv_sec * 1000000LL + (quint64)tstop.tv_nsec / 1000LL)-((quint64)tstart.tv_sec * 1000000LL + (quint64)tstart.tv_nsec / 1000LL);
Memory used
gzip | zlib | lz4 | lz4hc | none |
---|---|---|---|---|
gzip | zlib | lz4 | lz4hc | none |
0.5MB | 0.5MB | 0MB | 0MB | 0MB |
The socket is always used as full duplex, then it's compression + decompression memory.
Compression ratio
It's transferred size/raw size (lower is better)
With the benchmark application
Uploaded at: https://github.com/alphaonex86/debug-devel/tree/master/QTcpCompressionBenchmark
gzip | zlib | lz4 | lz4hc | none |
---|---|---|---|---|
gzip | zlib | lz4 | lz4hc | none |
0.99 | 0.97 | 1.59 | 1.59 | 1 |
The most over-head of small packet (3Bytes) is drop by high compression with zlib/gzip for the big packet.
Graphics
正在上传…重新上传取消 正在上传…重新上传取消
Quick benchmark on ARM64
A quick benchmark on ARM64 (odroid, Cortex A53), on kernel Image (12MB), use default compression level (-6) because no way to configure the compression level of btrfs
The speed is on compressed stream, mean the hdd.
xz | gzip | lz4 | zstd | |
---|---|---|---|---|
Size | 4.2M | 5.5M | 7.8M | 5.8M |
Compression speed | 0.2 MB/s | 1.8 MB/s | 21.4 MB/s | 2.8 MB/s |
Decompression speed | 4.8 MB/s | 13.6 MB/s | 48.4 MB/s | 19.1 MB/s |
压缩算法比较: Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO相关推荐
- 6.1-6.4 gzip、Bzip2、xz
6.1 压缩打包介绍 Linux环境常见压缩文件类型: .zip,.gz,.bz2,.xz, .tar.gz,.tar.bz2,.tar.xz 压缩打包的目的 方便文件传输 节省磁盘空间 减少传输花费 ...
- linux环境下常用的打包、压缩、解压命令(tar、gzip、bzip2、zip)
文章目录 前言 基础概念 打包/归档 压缩 解压 打包压缩 压缩解压命令 总结 前言 经常使用电脑的人常常会接触到压缩文件,不管是软件.数据还是资料,下载之后通常就是一个压缩包,在Windows平台上 ...
- c语言直接实现bzip2压缩方法,Linux普通文件压缩工具gzip、Bzip2、xz
第六章 文件压缩和打包 6.1 压缩打包介绍 Linux环境常见压缩文件类型: .zip,.gz,.bz2,.xz, .tar.gz,.tar.bz2,.tar.xz 压缩打包的目的 方便文件传输 节 ...
- linux gunzip r .tar,Linux命令之文件归档、压缩、解压缩tar,gzip,gunzip,bzip2,bunz -电脑资料...
tar 建立档案文件 [语法] tar [option] tarfile filename [命令说明] 文件名必须紧跟在-f参数后,且作为参数的最后一项; [参数说明] -c 建立一个新的档案文件; ...
- Linux下文件的打包、解压缩指令——tar,gzip,bzip2,unzip,rar
本文是笔者对鸟叔的Linux私房菜(基础学习篇) 第三版(中文网站)中关于 Linux 环境下打包和解压缩指令的内容以及日常操作过程中所接触的相关指令的总结和记录,以供备忘和分享.更多详细信息可直接参 ...
- 四周第四次课(1月5日) 6.1 压缩打包介绍 6.2 gzip压缩工具 6.3 bzip2压缩工具 6.4 xz压缩工具...
四周第四次课(1月5日) 6.1 压缩打包介绍 6.2 gzip压缩工具 6.3 bzip2压缩工具 6.4 xz压缩工具 ====================================== ...
- gzip、bzip2和tar
文章目录 1 gzip 1.1 查看 1.2 解压 1.3 压缩 2 bzip2 2.1 压缩 2.2 解压 3 tar 3.1 tar打包.gzip压缩 3.2 tar打包.bzip2压缩 单个文件 ...
- linux zip和tar的区别,Linux入门:tar、gzip、bzip2以及zip的区别
Linux入门:tar.gzip.bzip2以及zip的区别 tar命令 gzip以及bzip2命令 zip命令 区别 正文处理命令 tar命令 1.归档(archiving)就是将许多文件(或目录) ...
- 6.1-6.4 压缩打包介绍,压缩工具gzip,bzip2, xz
6.1 压缩打包介绍 6.2 gzip压缩工具 6.3 bzip2压缩工具 6.4 xz压缩工具 6.1 压缩打包介绍 常见压缩文件 windows .rar .zip .7z Linux .zi ...
最新文章
- 串口服务器支持多台上位机,RS485多机通信一台上位机两台下位机问题,
- 博客园markdown语法扩展
- python面试题及答案-50道Python面试题集锦(附答案)
- IT-标准化-系列-6.关闭事件跟踪程序
- 医疗器械软件安全性级别判定
- android硬编码封装mp4,【Android 音视频开发打怪升级:音视频硬解码篇】四、音视频解封和封装:生成一个MP4...
- 总结之前做项目中要注意的一些书写规范
- Prefuse 4未完
- 打开计算机打不开运行错误怎么办,注册表打不开,电脑出错注册表编辑器打不开怎么办?...
- 京东动态页面爬虫 scrapy+selenium
- OpenGL基础43:抗锯齿
- 检查pandas是否存在一列或者多列
- 从心理学角度看,如何提高招聘面试的准确率?
- 程序员常用的软件(附下载地址)
- zip命令加密和解密
- matlab 病态方程组,超定方程组与欠定方程组(病态方程组)
- Unity LOGO流光效果
- layui模板引擎嵌套
- java进阶知识思维导图
- 32位与64位CPU字长