I just ran a series of experiments. In this case, I'm running on an old linux machine, and copying from a local disk to a nas-mounted directory.

Using File::Copy : 129 seconds system("cp blah blah") : 171 seconds
Now I tried a different approach: @files is a list of the 250 files:
my $cmd = "cd $olddirectory; tar -cvf - " . join(' ',@files) . " | gzi +p -c -1 | (cd $newdirectory; gzip -c -d | tar -xvf -)"; system ($cmd); Using gzip -9 : 64 seconds Using gzip -1 : 57 seconds Without gzips : 52 seconds
All times are for copying 250 small files amounting to 1084k. I also found that times scaled symmetrically with number of files.

For what its worth, rsync was copying at the rate of approximately 3 files per second, so the perl/tar method is much faster. (I tried perl in the first place because this directory contains 1.5 million files - rsync was taking more than a day just to collect file info...)

In this case, its apparently more necessary to minimize processing power versus network usage (otherwise gzip -9 would be faster).

As always, your mileage may vary...


In reply to Re^2: Fastest way to copy a file from 1 direcotry to another directory by Anonymous Monk
in thread Fastest way to copy a file from 1 direcotry to another directory by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.