Posts Tagged ‘benchmark’

Useless fuss about ZIP and RAR

Saturday, February 24th, 2007

There has been some fuss generated by Jeff Atwood (who is a Windows developer, which is bad, and a Visual Basic one, which is worse), who seems, in my humble opinion, to be giving partial information around, as closed in his Windows-only world as he appears to be. In a recent article of his, Jeff makes a basic comparison between the ZIP and RAR compression systems. Unfortunately, most Windows people completely ignore that there’s something much better out there, that has been floating in the *nix world for quite a long time now. I’m talking about the powerful combination of tar and bzip2.

Let’s get to the facts right away. To experiment around, I’ve used a directory containing the source code of the Linux kernel, then I built that kernel, so that the size of the directory would be pretty big, and we would have both text files and binary files.

Here’s the size of the original directory:

$ du -sh /usr/src/linux-2.6.18.3
539M    linux-2.6.18.3

This is what happens with ZIP:

$ time zip -r ~/linux /usr/src/linux-2.6.18.3
...
real    2m35.917s
user    0m32.486s
sys     0m6.024s

$ ls -gGh ~/linux.zip
-rw-r--r-- 1 141M 2007-02-24 01:04 /home/siovene/linux.zip

Fine, 141Mb in 2 minutes and 35 seconds. Let’s try RAR:

$ time ./rar_static a ~/linux.rar /usr/src/linux-2.6.18.3
...
real    5m8.715s
user    2m14.012s
sys     0m12.473s

$ ls -gGh ~/linux.rar -lh
-rw-r--r-- 1 132M 2007-02-24 01:26 /home/siovene/linux.rar

Ouch! Double time and just a slightly better compression! Let’s try TAR and BZIP2:

$ time tar cv linux-2.6.18.3 | bzip2 > ~/linux.tar.bz2
...
real    4m22.265s
user    2m38.134s
sys     0m5.608s

$ ls -gGh ~/linux.tar.bz2
-rw-r--r-- 1 90M 2007-02-24 01:09 /home/siovene/linux.tar.bz2

Not too faster than RAR (but using two programs communicating through a pipe, so some overhead), but much more efficient! The compressed file is only 90Mb starting from an original uncompressed of 539Mb

Let’s summarize the data:

Method        Time        Size
zip           2m35s       141Mb
rar           5m08s       132Mb
tar.bz2       4m22s       90Mb

In conclusion, you should use the best tools, interdependently from their popularity, and remember that there is so much more than what you can see from your Windows-user-perspective.