Wednesday, 23 April 2014

GZIP vs BZIP2 - which one to use?

In case that you are wondering which one to use here are why thing you should consider!

First of all both of them are two most popular compressing tool in Linux.
Basic use of gzip command is

#gzip folder

Exit is folder.gz


Basic use of bzip2 is

#bzip2 folder

Exit is folder.bz

I archived var folder for this test.
root@ubuntus1:/var# du . -h -s *
381M    .
root@ubuntus1:/var# pwd
/var
root@ubuntus1:/var# du . -h -s *
381M    .
root@ubuntus1:/var# cd ..
root@ubuntus1:/# tar cvf var.tar var/

root@ubuntus1:/# ls -lh |grep var
drwxr-xr-x 13 root root 4.0K Sep  3  2013 var
-rw-r--r--  1 root root 374M Apr 23 07:21 var.tar



Which one to use?

Well it all depence! Here are few thing you should think off and few print screen.

1.CPU consamption
 Bzip is more CPU intensive.



 

2. File system size
Bzip save more file system space

root@ubuntus1:/# ls -lh |grep var
drwxr-xr-x 13 root root 4.0K Sep  3  2013 var
-rw-r--r--  1 root root 111M Apr 23 07:21 var.tar.bz2
-rw-r--r--  1 root root 122M Apr 23 07:22 var.tar.gz


3. Time of executing
Bzip takes longer to compress.

root@ubuntus1:/# time bzip2 var.tar

real    5m47.469s
user    4m40.246s
sys     0m4.588s

root@ubuntus1:/# time gzip var.tar

real    1m10.619s
user    0m41.587s
sys     0m3.912s




I always use gzip just because it is much faster! :)




No comments: