linux压缩文件校验,在Linux的压缩、解压命令的速度进行验证[多个CPU(多核心)] 互联网技术圈 互联网技术圈...

fcb443edfff4c0d7c2f42a2ad4ab5ac1.png

Linux的各种压缩命令的性能比较

在服务器管理的情况下,有很多人会因为容量不足而压缩不需要的文件。另外,如果对巨大的文件进行压缩的话,会非常耗费时间,对服务器产生负荷,也会影响到运用中的服务。

再加上压缩、解压的时间,就比什么都浪费时间了。因此,试着验证在Linux中提供的各种压缩、解压命令。

比较Linux的压缩、解压软件

在这里,我们试着利用各种Linux命令来测量压缩、解压的性能,能够尽快压缩和解压文件。

现在,在进行压缩、解压处理时,也有使用多个CPU(多核)进行压缩和解压的工具。用以下各种各样的工具进行了验证。

zip

gzip

pigz

pigz-11bzip2

lbzip2

pbzip2

xz

pxz

pixz

测试环境

验证使用的机器的规格如下。Ubuntu 17004和4 CPU,搭载的内存是8GB。

$ lsb_release-aNoLSB modules are available.

DistributorID: Ubuntu

Description: Ubuntu 17.04

Release: 17.04

Codename:zesty

$ cat/proc/cpuinfo

processor: 0vendor_id: GenuineIntelmodel name: Intel(R) Core(TM)i5-3470CPU@ 3.20GHzphysical id: 0siblings: 4core id: 0cpu cores: 4processor: 1vendor_id: GenuineIntelmodel name: Intel(R) Core(TM)i5-3470CPU@ 3.20GHzphysical id: 0siblings: 4core id: 1cpu cores: 4processor: 2vendor_id: GenuineIntelmodel name: Intel(R) Core(TM)i5-3470CPU@ 3.20GHzphysical id: 0siblings: 4core id: 2cpu cores: 4processor: 3vendor_id: GenuineIntelmodel name: Intel(R) Core(TM)i5-3470CPU@ 3.20GHzphysical id: 0siblings: 4core id: 3cpu cores: 4

$ cat/proc/meminfoMemTotal: 8044660kB

各Linux压缩·解压命令的验证

那么马上开始验证,首先制作成压缩对象的文件。制作的文件尺寸为10MB,因此使用dd命令制作成零的文件。

$ LANG=C ddif=/dev/zeroof=tmp.txt bs=1Mcount=10

10+0recordsin

10+0recordsout

10485760bytes(10MB, 10 MiB)copied, 0.0119667s, 876MB/s

$ ll-h tmp.txt-rw-rw-r-- 1foobar foobar10M 2017-09-14 10:43:23tmp.txt

如果制作了tmp.txt的10MB的文件,请执行以下的命令进行多次验证。以下是使用相同命令的压缩命令和解压缩命令,在压缩后以各工具连续进行解压。

time zip-q tmp.zip tmp.txt&&time unzip-qu tmp.zip&&rm tmp.zip

time gzip tmp.txt&&time gunzip tmp.txt.gz

time pigz tmp.txt&&time unpigz tmp.txt.gz

time pigz-11tmp.txt&&time unpigz tmp.txt.gz

time bzip2 tmp.txt&&time bunzip2 tmp.txt.bz2

time lbzip2 tmp.txt&&time lbunzip2 tmp.txt.bz2

time pbzip2 tmp.txt&&time pbzip2-d tmp.txt.bz2

time xz tmp.txt&&time unxz tmp.txt.xz

time pxz tmp.txt&&time unxz tmp.txt.xz

time pixz tmp.txt&&time pixz-d tmp.txt.xz

上述命令组进行了5次,试着取了那个平均值。那个结果如下。

验证結果 [ lbzip2 速度最快 ]

从这个结果来看,综合来看,压缩、解压共有lbzip2命令(压缩)和其解压命令的lbunzip2是压缩、解压性能非常优秀。

为了压缩10MB的文件,lbzip2要0.021秒,为了解压,lbunzip2命令要0.015秒,比其他命令是最快的。

作为次点pigZ命令也相当优秀。另外,CPU的利用率超过100%的东西显示了多个CPU。

相反,100%以下的命令不能使用多个CPU。

-----------------------+----------+-------------

压缩/解压 |CPU利用率 | 合計所要時間(秒)

-----------------------+----------|-------------zip-q tmp.zip tmp.txt| 99%cpu| 0.109total

unzip-qu tmp.zip| 0%cpu| 0.003total-----------------------+----------|-------------gzip tmp.txt| 97%cpu| 0.103total

gunzip tmp.txt.gz| 96%cpu| 0.083total-----------------------+----------|-------------pigz tmp.txt| 272%cpu| 0.037total

unpigz tmp.txt.gz| 163%cpu| 0.024total-----------------------+----------|-------------pigz-11tmp.txt| 394%cpu| 1.962total

unpigz tmp.txt.gz| 117%cpu| 0.027total-----------------------+----------|-------------bzip2 tmp.txt| 97%cpu| 0.095total

bunzip2 tmp.txt.bz2| 94%cpu| 0.059total-----------------------+----------|-------------lbzip2 tmp.txt| 243%cpu| 0.021total

lbunzip2 tmp.txt.bz2| 293%cpu| 0.015total-----------------------+----------|-------------pbzip2 tmp.txt| 257%cpu| 0.045total

pbzip2-d tmp.txt.bz2| 89%cpu| 0.036total-----------------------+----------|-------------xz tmp.txt| 99%cpu| 0.289total

unxz tmp.txt.xz| 94%cpu| 0.059total-----------------------+----------|-------------pxz tmp.txt| 101%cpu| 0.286total

unxz tmp.txt.xz| 93%cpu| 0.030total-----------------------+----------|-------------pixz tmp.txt| 97%cpu| 0.290total

pixz-d tmp.txt.xz| 91%cpu| 0.044total-----------------------+----------|-------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值