A bit about

Hello, everyone! All you can see below is just my bank of information. Some material I've found in the fathomless net, some I've learned myself. Don't think all of the information here is right or actual, but may be it could be of use for you :) All feedback is welcome, especially constructive ones :)

Wednesday, March 4, 2009

.tgz vs .tar.gz

Comparing the result, there is no difference between "old-style" archival of directories (by means of pipe: tar -c dir1 | gzip > arch1.tar.gz) and "new-style" (by means of integrated ability of tar: tar -czf arch1.tgz dir1).

But there is a huge difference in speed. I tried to archive a large directory these 2 ways and obtained completely the same archives. I used "time" Linux tool to measure execution time. The first method (with pipe) took about 40 minutes to complete. The second method - 12.

The reason of the difference, I guess, in usage of pipe in the first method. Shell creates a temporary file for each pipe and all stdout of one application is stored into this file. Another application gets this file as stdin. We obtain the next sequence: reading of source directory, writing pipe temporary file, reading the temporary file and writing the archive file. In the second method we have only two of these actions: reading of source directory and writing to the target archive file.

0 comments:

Post a Comment