在Linux的压缩、解压命令的速度进行验证[多个CPU(多核心)]

  • 在Linux的压缩、解压命令的速度进行验证[多个CPU(多核心)]已关闭评论
  • 1,712 views
  • A+
所属分类:linux

在Linux的压缩、解压命令的速度进行验证[多个CPU(多核心)]

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

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

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

比较Linux的压缩、解压软件

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

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

zip
gzip
pigz
pigz -11
bzip2
lbzip2
pbzip2
xz
pxz
pixz

 

测试环境

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

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.04
Release:        17.04
Codename:       zesty
$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
model name      : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4

processor       : 1
vendor_id       : GenuineIntel
model name      : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4

processor       : 2
vendor_id       : GenuineIntel
model name      : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
physical id     : 0
siblings        : 4
core id         : 2
cpu cores       : 4

processor       : 3
vendor_id       : GenuineIntel
model name      : Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
physical id     : 0
siblings        : 4
core id         : 3
cpu cores       : 4
$ cat /proc/meminfo
MemTotal:        8044660 kB

 

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

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

$ LANG=C dd if=/dev/zero of=tmp.txt bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.0119667 s, 876 MB/s

$ ll -h tmp.txt
-rw-rw-r-- 1 foobar foobar 10M 2017-09-14 10:43:23 tmp.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 -11       tmp.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.109 total
unzip -qu tmp.zip      |   0% cpu | 0.003 total
-----------------------+----------|-------------
gzip      tmp.txt      |  97% cpu | 0.103 total
gunzip    tmp.txt.gz   |  96% cpu | 0.083 total
-----------------------+----------|-------------
pigz      tmp.txt      | 272% cpu | 0.037 total
unpigz    tmp.txt.gz   | 163% cpu | 0.024 total
-----------------------+----------|-------------
pigz -11  tmp.txt      | 394% cpu | 1.962 total
unpigz    tmp.txt.gz   | 117% cpu | 0.027 total
-----------------------+----------|-------------
bzip2     tmp.txt      |  97% cpu | 0.095 total
bunzip2   tmp.txt.bz2  |  94% cpu | 0.059 total
-----------------------+----------|-------------
lbzip2    tmp.txt      | 243% cpu | 0.021 total
lbunzip2  tmp.txt.bz2  | 293% cpu | 0.015 total
-----------------------+----------|-------------
pbzip2    tmp.txt      | 257% cpu | 0.045 total
pbzip2 -d tmp.txt.bz2  |  89% cpu | 0.036 total
-----------------------+----------|-------------
xz        tmp.txt      |  99% cpu | 0.289 total
unxz      tmp.txt.xz   |  94% cpu | 0.059 total
-----------------------+----------|-------------
pxz       tmp.txt      | 101% cpu | 0.286 total
unxz      tmp.txt.xz   |  93% cpu | 0.030 total
-----------------------+----------|-------------
pixz      tmp.txt      |  97% cpu | 0.290 total
pixz -d   tmp.txt.xz   |  91% cpu | 0.044 total
-----------------------+----------|-------------

 

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar